简体   繁体   English

使用Metro客户端缓冲传入的SOAP消息时发生错误

[英]Error occurred while buffering incoming SOAP message using Metro client

I am using Metro 2 client to consume the "Secure wcf web service in Java". 我正在使用Metro 2客户端来使用“Java中的安全wcf Web服务”。 But Metro client does not gives any response and stay in hang mode after very long time it produce the output as an error: 但是,在很长一段时间后,Metro客户端没有给出任何响应并保持挂起模式,因为它产生的输出是错误的:

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. 我试图解决这个问题,但没有运气,Metro客户端无法以正确的方式解析SOAP响应。 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 . 我使用的是Netbeans 7.1Metro 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: req包含以下内容:

<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. 但它在输出中生成Source并在请求中获取SOAP信封。

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 . 我认为数据网络服务返回客户端包含非法字符0x1a ,即EOF
XML doesn't allow CONTROL CHAR in it. XML不允许使用CONTROL CHAR。 As you are using SOAP ultimately XML. 当您使用SOAP最终XML时。

See the similar issue: illegal character in xml document 看到类似的问题: xml文档中的非法字符

solution: 解:
1. Either you can eliminate CONTROL char 1.要么你可以消除CONTROL char
2. Or Encode it in web-service and decode it at SOAP client. 2.或者在Web服务中对其进行编码并在SOAP客户端对其进行解码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 初始化Metro WebService客户端时出错 - Error while initializing metro webservice client SOAP 1.2 消息在发送到 SOAP 1.1 端点时无效 WSDL 中使用 SOAP 1.2 时出现错误 - A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint Error While Using SOAP 1.2 in WSDL 在Spring MVC应用程序中使用CXF创建SOAP客户端时出错 - Error while creating SOAP client using CXF in Spring MVC application 处理传入 SOAP 消息的问题 - Problems with handling incoming SOAP message 仅配置了SOAP12,但收到错误消息“传入的SOAP消息协议是1.1版” - Only SOAP12 is configured, but got error “Incoming SOAP message protocol is version 1.1” 如何在使用Axis 1.4 wsdl2java生成的客户端时获取SOAP消息 - How to get SOAP message while using a Axis 1.4 wsdl2java-generated client 使用房间时发生 Parcelable 错误 - Parcelable error occurred while using the Room 执行从Maven构建的jar时出现“发生Java错误”消息 - “Java error occurred” message while executing a jar built from maven Jersey,写入响应消息时发生 I/O 错误 - Jersey, An I/O error has occurred while writing a response message 在IBM MQ Lite中推送消息时发生错误 - Error is occurred while pushing the Message in IBM MQ Lite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM