我有一个从SOAP 1.2 WSDL文件创建的WebService客户端。当我在客户端调用一个方法时,它会创建SOAP 1.2消息(我可以看到它并在处理程序中添加时间戳),但是我得到了
Caused by: javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.1 Message
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:75)
创建了SOAPMessage示例:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" S:mustUnderstand="true">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-B02FCFB46EE225EA3214213243149751">gfdgdfgdfzx</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-3">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="S"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#TS-1">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse S"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>Cadsad</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#id-2">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>Q0ZZurxhe0OjNOMzI7jziQ1K5Cbmue9U6L+fjGKG2aE=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>adasdsadsad==</ds:SignatureValue>
<ds:KeyInfo Id="KI-B02FCFB46EE225EA3214213243149772">
<wsse:SecurityTokenReference wsu:Id="STR-B02FCFB46EE225EA3214213243149803">
<wsse:Reference URI="#X509-B02FCFB46EE225EA3214213243149751" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
<wsu:Timestamp wsu:Id="TS-1">
<wsu:Created>2015-01-15T12:18:32.998Z</wsu:Created>
<wsu:Expires>2015-02-14T12:18:32.998Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</S:Header>
<S:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-2">
<ns2:sendDocumentFile xmlns:ns2="http://asd.webservice.com/">
<Attachment>
<fileName>adsad</fileName>
</Attachment>
</ns2:sendDocumentFile>
</S:Body>
</S:Envelope>
WSDL文件:
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://webservice.df.com/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="WSService" targetNamespace="http://webservice.df.com/">
<wsdl:types>
<xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://webservice.df.com/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://webservice.df.com/">
<xs:import namespace="http://www.w3.org/2005/05/xmlmime"/>
<xs:element name="getBatchStatus" type="tns:getBatchStatus"/>
<xs:element name="getBatchStatusResponse" type="tns:getBatchStatusResponse"/>
<xs:element name="receiveDocumentFile" type="tns:receiveDocumentFile"/>
<xs:element name="receiveDocumentFileResponse" type="tns:receiveDocumentFileResponse"/>
<xs:element name="sendDocumentFile" type="tns:sendDocumentFile"/>
<xs:element name="sendDocumentFileResponse" type="tns:sendDocumentFileResponse"/>
<xs:complexType name="sendDocumentFile">
<xs:sequence>
<xs:element minOccurs="0" name="Attachment" type="tns:attachment"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="attachment">
<xs:sequence>
<xs:element name="fileName" type="xs:string"/>
<xs:element name="binaryData" type="xs:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sendDocumentFileResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getBatchStatus">
<xs:sequence>
<xs:element minOccurs="0" name="packID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getBatchStatusResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:cond"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="cond">
<xs:sequence>
<xs:element minOccurs="0" name="condDesc" type="xs:string"/>
<xs:element name="condKodu" type="xs:int"/>
<xs:element minOccurs="0" name="packIdentifier" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="receiveDocumentFile">
<xs:sequence>
<xs:element minOccurs="0" name="PaketID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="receiveDocumentFileResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:attachment"/>
</xs:sequence>
</xs:complexType>
<xs:element name="WSFault" type="tns:WSFault"/>
<xs:complexType name="WSFault">
<xs:sequence>
<xs:element name="code" nillable="true" type="xs:int"/>
<xs:element name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getBatchStatusResponse">
<wsdl:part element="tns:getBatchStatusResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sendDocumentFile">
<wsdl:part element="tns:sendDocumentFile" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sendDocumentFileResponse">
<wsdl:part element="tns:sendDocumentFileResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="WSFault">
<wsdl:part element="tns:WSFault" name="WSFault">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getBatchStatus">
<wsdl:part element="tns:getBatchStatus" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="receiveDocumentFileResponse">
<wsdl:part element="tns:receiveDocumentFileResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="receiveDocumentFile">
<wsdl:part element="tns:receiveDocumentFile" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WS">
<wsdl:operation name="sendDocumentFile">
<wsdl:input message="tns:sendDocumentFile" name="sendDocumentFile">
</wsdl:input>
<wsdl:output message="tns:sendDocumentFileResponse" name="sendDocumentFileResponse">
</wsdl:output>
<wsdl:fault message="tns:WSFault" name="WSFault">
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getBatchStatus">
<wsdl:input message="tns:getBatchStatus" name="getBatchStatus">
</wsdl:input>
<wsdl:output message="tns:getBatchStatusResponse" name="getBatchStatusResponse">
</wsdl:output>
<wsdl:fault message="tns:WSFault" name="WSFault">
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="receiveDocumentFile">
<wsdl:input message="tns:receiveDocumentFile" name="receiveDocumentFile">
</wsdl:input>
<wsdl:output message="tns:receiveDocumentFileResponse" name="receiveDocumentFileResponse">
</wsdl:output>
<wsdl:fault message="tns:WSFault" name="WSFault">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WSServiceSoapBinding" type="tns:WS">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendDocumentFile">
<soap12:operation soapAction="urn:SendDocumentFile" style="document"/>
<wsdl:input name="sendDocumentFile">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="sendDocumentFileResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WSFault">
<soap12:fault name="WSFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getBatchStatus">
<soap12:operation soapAction="urn:GetBatchStatus" style="document"/>
<wsdl:input name="getBatchStatus">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBatchStatusResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WSFault">
<soap12:fault name="WSFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="receiveDocumentFile">
<soap12:operation soapAction="urn:ReceiveDocumentFile" style="document"/>
<wsdl:input name="receiveDocumentFile">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="receiveDocumentFileResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WSFault">
<soap12:fault name="WSFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSService">
<wsdl:port binding="tns:WSServiceSoapBinding" name="WSPort">
<soap12:address location="https://apptest.df.com/df/services/WSPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
答案 0 :(得分:4)
我刚刚解决了更改系统配置的问题。 我把这些属性值放在代码中,问题就消失了。
System.setProperty("javax.xml.soap.MessageFactory""com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl");
System.setProperty("javax.xml.bind.JAXBContext", "com.sun.xml.internal.bind.v2.ContextFactory");