I'm using jaxb2-marshaller to generate classes to communicate with a webservice. Java-classes are generated with use of wsdl files.
I consume some operations without problems, but with one in a specific scenario where the response don't has the namespace on the tag.
For one operation i got the response like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.xxx.xxx/xxxxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<outputType>
<test>1</test>
</outputType>
</soapenv:Body>
</soapenv:Envelope>
And i call it with WebServiceTemplate from springframework
public int test(String command) throws Exception {
InputType input = new InputType();
input.setCommandName(command);
ObjectFactory objFactory = new ObjectFactory();
JAXBElement<InputType> jaxbData = objFactory.createSendRemoteComand(input);
JAXBElement<OutputType> response = (JAXBElement<OutputType>) getWebServiceTemplate()
.marshalSendAndReceive(jaxbData);
return response.getValue().getTest();
}
And i receive the stack error below because the XML "outputType" don't have the namespace like "tns:outputType", i discovery it mocking response in SOAP UI.
javax.xml.bind.UnmarshalException: elemento inesperado (uri:"", local:"outputType").
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:247) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:242) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:109) ~[na:1.8.0_131]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1131) ~[na:1.8.0_131]
Would anyone know a way to deal with the problem?
Related
I have a soap request like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://secbrupdtreq.xsd">
<soapenv:Header/>
<soapenv:Body>
<sec:UpdateRequest>
<sec:SourceName>ACES</sec:SourceName>
<sec:AgmntXrefBusKey>001~0011256482196</sec:AgmntXrefBusKey>
<sec:IndividualAgreementId></sec:IndividualAgreementId>
<sec:CustomerRolePlayerId></sec:CustomerRolePlayerId>
<sec:AnnualIncomeAmt></sec:AnnualIncomeAmt>
<sec:RiskToleranceCode></sec:RiskToleranceCode>
<sec:RiskToleranceCodeTxt></sec:RiskToleranceCodeTxt>
<sec:Occupation></sec:Occupation>
<sec:NASDAffiliation></sec:NASDAffiliation>
<sec:NetWorthCode></sec:NetWorthCode>
<sec:NetWorthCodeTxt></sec:NetWorthCodeTxt>
<sec:DeclaredNetWorthAmt></sec:DeclaredNetWorthAmt>
<sec:LastSuitabilityReviewDt></sec:LastSuitabilityReviewDt>
<sec:SuitabilityInScopeFlag></sec:SuitabilityInScopeFlag>
<sec:SuitabilityOutofScopeReasonCode></sec:SuitabilityOutofScopeReasonCode>
<sec:SuitabilityOutofScopeReasonTxt></sec:SuitabilityOutofScopeReasonTxt>
<sec:CreationTs></sec:CreationTs>
<sec:SUSAgreementId></sec:SUSAgreementId>
<sec:CategoryId1>45</sec:CategoryId1>
<sec:CategoryId2></sec:CategoryId2>
<sec:CategoryId3></sec:CategoryId3>
</sec:UpdateRequest>
</soapenv:Body>
</soapenv:Envelope>
In soap ui I am getting
"org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified".
I am using Java 1.8.
How can I solve this problem?
Try to add the xml-header with encoding type of your request:
<?xml version="1.0" encoding="UTF-8"?>
Why am I getting this error:
ERROR: 'Namespace for prefix 'xsi' has not been declared.'
Here is my Java code:
package com.emp.ma.jbl.nsnhlrspmlpl.nsnhlrspmlpl.internal.action;
import com.emp.ma.util.xml.XMLDocument;
import com.emp.ma.util.xml.XMLDocumentBuilder;
public class yay {
public static void main(String[] args) {
XMLDocument xmldoc = XMLDocumentBuilder.newDocument().addRoot("spml:modifyRequest");
xmldoc.gotoRoot().addTag("modification").addText("");
xmldoc.gotoChild("modification").addTag("valueObject").addText("");
xmldoc.gotoChild("valueObject").addAttribute("xsi:type","halo");
System.out.println(xmldoc);
}
}
This code was functioning properly until I tried throwing transformer exception whilst converting XML file to HTML for experimenting only.
I need to create an xml file with the format:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<spml:modifyRequest>
<modification>
<valueObject xsi:type="halo">
</valueObject>
</modification>
</spml:modifyRequest>
I removed the transformer part from the code already and yet I'm getting this error in eclipse:
ERROR: 'Namespace for prefix 'xsi' has not been declared.'
Exception in thread "main" com.emp.ma.util.xml.XMLDocumentException: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.emp.ma.util.xml.XMLDocumentImpl.toResult(XMLDocumentImpl.java:1244)
at com.emp.ma.util.xml.XMLDocumentImpl.toStream(XMLDocumentImpl.java:1314)
at com.emp.ma.util.xml.XMLDocumentImpl.toString(XMLDocumentImpl.java:1336)
at com.emp.ma.util.xml.XMLDocumentImpl.toString(XMLDocumentImpl.java:1325)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.emp.ma.util.xml.XMLDocumentBuilder$XMLDocumentHandler.invoke(XMLDocumentBuilder.java:55)
at $Proxy1.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.io.PrintStream.println(Unknown Source)
at com.emp.ma.jbl.nsnhlrspmlpl.nsnhlrspmlpl.internal.action.yay.main(yay.java:13)
Caused by: javax.xml.transform.TransformerException: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.emp.ma.util.xml.XMLDocumentImpl.toResult(XMLDocumentImpl.java:1242)
... 12 more
Caused by: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.sun.org.apache.xml.internal.serializer.SerializerBase.getNamespaceURI(Unknown Source)
at com.sun.org.apache.xml.internal.serializer.SerializerBase.addAttribute(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
... 15 more
I'm stuck because of this one exception and I don't know how to undo this. Please do help. Like i said, it was functioning properly before trying this experiment of mine, if possible how do I remove this transformer integration. I've tried changing workspace as well -- still not working.
For an XML document to be well-formed, all used namespace prefixes must be declared.
Simply declare the xsi namespace prefix on the root element of your XML,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<spml:modifyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modification>
<valueObject xsi:type="halo">
</valueObject>
</modification>
</spml:modifyRequest>
and your error will go away.
Note that you'll similarly have to define the spml namespace prefix.
I got the same error "AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server faultSubcode: faultString: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared." while calling the soap web service from coldfusion 9 server, as the error does not resolve quickly as I had to spent more time, finnaly found that due to the incorrect date value supplying to the webservice parameters, it throws different issue. Whenever we got this issue please check input values that are supplying to the webservcie parameters. In my case due to the datetime format 2015-03-04T00:00:00.000Z(It's a part of ISO-8601 date representation), issue happened, 2015-03-04 00:00 resolves the issue. For example for datetime If I provide string(xxxx), coldfusion axis webservice shows te irrelevant error --Namespace for prefix 'xsi' has not been declared....
I'm using jax-ws 2.2.7 to produce a web service. The operation signature is:
#WebMethod
#RequestWrapper(localName = "setInvocationAddress", targetNamespace = "http://services.choreos.org/", className = "org.choreos.services.SetInvocationAddress")
#ResponseWrapper(localName = "setInvocationAddressResponse", targetNamespace = "http://services.choreos.org/", className = "org.choreos.services.SetInvocationAddressResponse")
#Action(input = "http://services.choreos.org/ShopEntrance/setInvocationAddressRequest", output = "http://services.choreos.org/ShopEntrance/setInvocationAddressResponse")
public void setInvocationAddress(
#WebParam(name = "arg0", targetNamespace = "") String arg0,
#WebParam(name = "arg1", targetNamespace = "") String arg1,
#WebParam(name = "arg2", targetNamespace = "") List<String> arg2);
This web service is running on Tomcat 6 with java 7.
I have sent the following SOAP message to it:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pre="http://services.choreos.org/">
<SOAP-ENV:Body>
<pre:setInvocationAddress>
<arg0>CD-shopentrance-marketingapplication</arg0>
<arg1>marketingapplication</arg1>
<arg2>http://localhost:8080/marketingapplication/marketingapplication</arg2>
</pre:setInvocationAddress>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In localhost environment it works. But not in production.
When things did not work, I got the following stack trace at the server side (tomcat log):
May 24, 2015 11:29:04 PM com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit handle
SEVERE: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:317)
at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:344)
at com.sun.xml.ws.transport.http.HttpAdapter.access$400(HttpAdapter.java:100)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:634)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:264)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:218)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.xml.ws.streaming.XMLStreamReaderException: XML reader error: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.wrapException(XMLStreamReaderUtil.java:326)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:99)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:169)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:104)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:202)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:338)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:156)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:312)
... 22 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Non-default namespace can not map to empty URI (as per Namespace 1.0 # 2) in XML 1.0 documents
at [row,col {unknown-source}]: [1,90]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:464)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3058)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2941)
at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2078)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2058)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:96)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:80)
... 28 more
Someone has some idea of what happens?
Tks!!!
As the exception says, you cannot have blank target namespace.
It should be:
#WebParam(name = "arg0", targetNamespace = "http://services.choreos.org/")
Seems like JAX-WS generated the wrong annotation or you have some problem with your WSDL/XSD.
I am using Metro 2 client to consume the "Secure wcf web service in Java". But Metro client does not gives any response and stay in hang mode after very long time it produce the output as an error:
Stack Trace:
SEVERE: WSSMSG0001: Error occurred while buffering incoming SOAP message.
com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x1a
at [row,col {unknown-source}]: [1,6396222]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)
at com.ctc.wstx.sr.StreamScanner.reportIllegalChar(StreamScanner.java:2442)
at com.ctc.wstx.sr.StreamScanner.validateChar(StreamScanner.java:2389)
at com.ctc.wstx.sr.StreamScanner.resolveCharEnt(StreamScanner.java:2355)
at com.ctc.wstx.sr.StreamScanner.fullyResolveEntity(StreamScanner.java:1501)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2726)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1065)
at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.bridge(XMLStreamReaderToXMLStreamWriter.java:142)
at com.sun.xml.ws.message.stream.StreamMessage.writePayloadTo(StreamMessage.java:376)
at com.sun.xml.ws.message.stream.StreamMessage.writeEnvelope(StreamMessage.java:412)
at com.sun.xml.ws.message.stream.StreamMessage.writeTo(StreamMessage.java:390)
at com.sun.xml.ws.security.message.stream.LazyStreamBasedMessage.readMessage(LazyStreamBasedMessage.java:476)
at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.verifyInboundMessage(SecurityTubeBase.java:444)
at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processClientResponsePacket(SecurityClientTube.java:434)
at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processResponse(SecurityClientTube.java:362)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:972)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:910)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:873)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:775)
at com.sun.xml.ws.client.Stub.process(Stub.java:429)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:168)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
at $Proxy44.pullCustomers(Unknown Source)
at com.tekriti.client.Client.test(Client.java:106)
at com.tekriti.client.Client.main(Client.java:44)
com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.stream.XMLStreamException: Internal XSB error: Invalid State=0]
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:141)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
at $Proxy44.pullCustomers(Unknown Source)
at com.tekriti.client.Client.test(Client.java:106)
at com.tekriti.client.Client.main(Client.java:44)
Caused by: javax.xml.bind.UnmarshalException
I am trying to fix this issue but no luck, Metro client is unable to parse the SOAP response in a correct way. I don't know where I am doing mistake or I have to use something else.
I am using Netbeans 7.1 and Metro 2.2.
Please give your suggestions or if you had such problem in your past please do share with me.
updated:
This is working fine:
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
((BindingProvider)sourceDispatch).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://cdx.dealerbuilt.com/Api/0.97/IStandardApi/PullCustomers");
((BindingProvider)sourceDispatch).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
req contains the below one:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action>http://cdx.dealerbuilt.com/Api/0.97/IStandardApi/PullCustomers</Action>
</s:Header>
<s:Body>
<PullCustomers xmlns="http://cdx.dealerbuilt.com/Api/0.97/">
<searchCriteria xmlns:d4p1="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:ActivityStoreIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:long>64</d5p1:long>
</d4p1:ActivityStoreIds>
<d4p1:EnvironmentIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:long>27</d5p1:long>
</d4p1:EnvironmentIds>
</searchCriteria>
</PullCustomers>
</s:Body>
</s:Envelope>
But it produces Source in output and takes SOAP envelope in request.
I Need this should be work.
org.tempuri.StandardApi service = new org.tempuri.StandardApi();
CustomerSearchCriteriaType criteriaType = new CustomerSearchCriteriaType();
QName environmentQName = new QName("http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi", "EnvironmentIds");
ArrayOflong arrayOflong = new ArrayOflong();
arrayOflong.getLong().add(27l);
JAXBElement<ArrayOflong> environmentIds = new JAXBElement<ArrayOflong>(environmentQName, ArrayOflong.class, arrayOflong);
criteriaType.setEnvironmentIds(environmentIds);
QName activityQName = new QName("http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi", "ActivityStoreIds");
ArrayOflong arrayOfActivity = new ArrayOflong();
arrayOfActivity.getLong().add(64l);
JAXBElement<ArrayOflong> activityIds = new JAXBElement<ArrayOflong>(activityQName, ArrayOflong.class, arrayOfActivity);
criteriaType.setActivityStoreIds(activityIds);
ArrayOfCustomerType customers = service.getCustomBindingIStandardApi().pullCustomers(criteriaType);
if (customers != null) {
System.out.println("Size of Customers::::" + customers.getCustomer().size());
}
Request contains
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<PullCustomers xmlns="http://cdx.dealerbuilt.com/Api/0.97/">
<searchCriteria>
<ActivityStoreIds xmlns="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi">
<long xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">64</long>
</ActivityStoreIds>
<EnvironmentIds xmlns="http://schemas.datacontract.org/2004/07/DealerBuilt.BaseApi">
<long xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">27</long>
</EnvironmentIds>
</searchCriteria>
</PullCustomers>
</soapenv:Body>
</soapenv:Envelope>
But it hangs while producing output and after very long time it produce the error mentioned above.
Is the difference between the requests causes the problem or something else?
I think the data web-service is returning to client contain illegal character 0x1a which is EOF.
XML doesn't allow CONTROL CHAR in it. As you are using SOAP ultimately XML.
See the similar issue: illegal character in xml document
solution:
1. Either you can eliminate CONTROL char
2. Or Encode it in web-service and decode it at SOAP client.
We're running an Axis 1 Java client. The web service will sometime return an HTTP error code 500 along with some meaningless HTML body content. In such cases, we get a
javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
I'm certain there's an easy way to catch HTTP errors such that no class attempts to read the SOAP envelope, but I haven't been able to find the right terms to google.
How do I configure Axis (client-config.wsdd) or which handlers do I need to implement so that a webservice reply with an HTTP error code >= 400 can be properly handled?
Thanks
Simon
The cause is in Axis itself.
org.apache.axis.transport.http.HTTPSender#readFromSocket()
will log (level debug)
log.debug(outMsg.getSOAPEnvelope().toString());
If there is no valid SOAP envelope, that call causes the stacktrace above.
Simon