Error while buffering incoming SOAP message using Metro client

I am using the Metro 2 client to use the "Secure wcf web service in Java". But the Metro client does not give any answer and remains in freeze mode after a very long time, it displays the result 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 problem, but with no luck, the Metro client cannot parse the SOAP response correctly. I don’t know where I am going wrong, or I need to use something else.
I am using Netbeans 7.1 and Metro 2.2.

Please give your suggestions or if you have encountered such a problem in the past, please share with me.

updated

This works 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 following:

 <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 on the output and accepts the SOAP request in the request.

I need this to 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()); } 

The 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 freezes at release and after a very long time gives an error mentioned above.

Is the difference between the requests causing a problem or something else?

+6
source share
1 answer

I think the data web service is being returned to the client, contains an invalid character 0x1a , which is EOF .
XML does not allow CONTROL CHAR in it. Because you are using SOAP ultimately XML.

See a similar problem: illegal character in XML document

decision:
1. Or you can eliminate the CONTROL char
2. Or Encode it in a web service and decode it on a SOAP client.

+6
source

Source: https://habr.com/ru/post/912212/


All Articles