Narayanan Ramachandran

Greenhorn
+ Follow
since Dec 18, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Narayanan Ramachandran

Team,

Could you please tell me the best UML Designer and Code generation Eclipse Plugin. I have worked with RSA and indeed is the best tool. But I wanted an Eclipse Plugin. Something which can do both will be great.

I know there are many. But wanted to work with the best one.

Please give me the Exact name which I can search in Market Place or send me the URL.

I am looking plugins for both Eclipse Juno Version and Indogo (v3.7)

Please help.

Thanks,
Narayan
10 years ago
Hi Team,

I have a Java class which uses JAXB to unmarshal a Java object to XML. Beloe is the code. It is using setSchema to set the reference of an external XSD file.

JAXBContext jaxbContext = JAXBContext.newInstance(MySimpleOrder.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
SchemaFactory sf =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(
new URL("http://soabook.com/example/oms/simpleorder.xsd"));
jaxbMarshaller.setSchema(schema);
ByteArrayOutputStream ba = new ByteArrayOutputStream();
jaxbMarshaller.marshal(myOrder, ba);
System.out.println(ba.toString());

This is failing when running through Eclipse in my Comany network because it is unable to locate the XSD file. I tried with proxy setting also. Still it failed. But in my client VPN, this is working fine. This is failing when executed with Command prompt also. But through my company network, I am able to access the XSD file through the browser.
Issue 1: Exception when executed in my company network (Not able to identify the XSD file)
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://soabook.com/example/oms/simpleorder.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:2541)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2528)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1825)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:531)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:594)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:626)
at com.jaxb.startfromjava.MySimpleOrderSerializer.main(MySimpleOrderSerializer.java:52)


Again, when I am trying to execute the code in the client VPN, I am getting an exception. Which happens during the marshalling process. Here I am getting another exception as below. But the XSD contains sn element simpleOrder and the corresponding class is also annotated appropriately.

javax.xml.bind.MarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'simpleOrder'.]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:317)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
at com.jaxb.startfromjava.MySimpleOrderSerializer.main(MySimpleOrderSerializer.java:56)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'simpleOrder'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1916)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:549)
at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
at com.sun.xml.internal.bind.v2.runtime.output.SAXOutput.endStartTag(SAXOutput.java:113)
at com.sun.xml.internal.bind.v2.runtime.output.ForkXmlOutput.endStartTag(ForkXmlOutput.java:91)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.endAttributes(XMLSerializer.java:274)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:560)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:290)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:462)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314)
... 3 more

Could you please tell me where I am wrong here?
11 years ago

Cosmin Nicolae Vacaroiu wrote:Worked for me. Thanks.



Hi Team,

The SOAP call was successful and the operation succeeded without any issue. But the call is always returning 0 records. Any idea? I have done all the changes as suggested by Karl.

Also I am not able to submit this using SOAP UI also. It is always throwing the below fault. Please advise on the same as well.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">
<soapenv:Body>
<soapenv:Fault>
<faultcode>aws:Client.MissingParameter</faultcode>
<faultstring>The request must contain the parameter Signature.</faultstring>
<detail>
<aws:RequestId>cf96391c-5ca2-4df1-94bb-3df1aaae3f6a</aws:RequestId>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

Please advise.
11 years ago