Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SOAP头标记和命名空间仅出现在响应中_Java_Xml_Web Services_Soap_Xml Signature - Fatal编程技术网

Java SOAP头标记和命名空间仅出现在响应中

Java SOAP头标记和命名空间仅出现在响应中,java,xml,web-services,soap,xml-signature,Java,Xml,Web Services,Soap,Xml Signature,我在服务器中部署了一个Web服务,一个客户端正在对其进行请求。我拥有建立SSL连接的客户端和服务器证书,在服务器端构建签名,然后客户端尝试验证它。 问题是,当服务器签署SOAP消息时,它看起来像这样: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"> <S:Body> <

我在服务器中部署了一个Web服务,一个客户端正在对其进行请求。我拥有建立SSL连接的客户端和服务器证书,在服务器端构建签名,然后客户端尝试验证它。 问题是,当服务器签署SOAP消息时,它看起来像这样:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns2:ResponseMessage xmlns="urn:iec62325.504:messages:1:0" xmlns:ns2="http://iec.ch/TC57/2011/schema/message">
<ns2:Header>
<ns2:Verb>reply</ns2:Verb>
<ns2:Noun>QueryData</ns2:Noun>
<ns2:Timestamp>2016-11-17T15:44:51Z</ns2:Timestamp>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<DigestValue>yLDpd7Nck0LUBDjoKHM/uh/iCad2v5GhFR+7GTWBNh0=</DigestValue>
</Reference>
</SignedInfo>
    <SignatureValue>iovrYXAs+UttPJmu+5kZvnQ6P7XqhfrFd6nEgtArCRT/BwsIZlo6QYH5nCK/M67jCVTHcRso0KDa
o/1YUeZLi6btLu0I9rNKrlXEp7x08ZRrG0sCqaGV//8AK4jnQDJ7TR4At0lfJg/JMniNAxmTCb3M
Py6iP5t4LVlvRPVEb1G44uCzMTjtcseTEPJ+/k+CIsOqQ5zA4Srk05bMdkkse62bGqMPMoqBpU0K
5r29Wl0ZXre/tIt5LJ/7el27MtaIqpo+9CgroFJZUIu6p8Em5p5/s4c5VknWCK2VZVGe7vhjHuiN
vUlbVWV0DiXHC92jQ2Ty4BTMGABALY40h2V7Bg==</SignatureValue>
<KeyInfo>
<X509Data>
...

回复
槲寄生
2016-11-17T15:44:51Z
yLDpd7Nck0LUBDjoKHM/uh/iCad2v5GhFR+7GTWBNh0=
iovrYXAs+UttPJmu+5kZvnQ6P7XqhfrFd6nEgtArCRT/BwsIZlo6QYH5nCK/M67jCVTHcRso0KDa
o/1YUeZLi6btLu0I9rNKrlXEp7x08ZRrG0sCqaGV//8AK4jnQDJ7TR4At0lfJg/JMniNAxmTCb3M
Py6iP5t4LVlvRPVEb1G44uCzMTjtcseTEPJ+/k+CISOQ5ZA4SRK05BMDKKSE62BGQMPMOQBPU0K
5r29Wl0ZXre/tIt5LJ/7el27MtaIqpo+9CGROFJZU6P8EM5P5/s4c5VknWCK2VZVGe7vhjHuiN
vUlbVWV0DiXHC92jQ2Ty4BTMGABALY40h2V7Bg==
...
当客户端的句柄捕获消息时,它看起来如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<S:Body>
<ns2:ResponseMessage xmlns="urn:iec62325.504:messages:1:0" xmlns:ns2="http://iec.ch/TC57/2011/schema/message">
<ns2:Header>
<ns2:Verb>reply</ns2:Verb>
<ns2:Noun>QueryData</ns2:Noun>
<ns2:Timestamp>2016-11-17T15:44:51Z</ns2:Timestamp>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
...

回复
槲寄生
2016-11-17T15:44:51Z
...
发送和接收之间的某些内容正在插入此命名空间:

xmlns:env=”http://www.w3.org/2003/05/soap-envelope"

还有这个空标签:

因此,客户端无法验证签名

WebService由Netbeans向导通过以下带有JAX-WS的wsdl生成:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:cmsg="urn:iec62325.504:messages:1:0" xmlns:wss="urn:iec62325.504:wss:1:0"
    xmlns:msg="http://iec.ch/TC57/2011/schema/message" targetNamespace="urn:iec62325.504:wss:1:0">
    <types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:import namespace="urn:iec62325.504:messages:1:0"
                schemaLocation="../xsd/urn-iec62325-504-messages-1-0.xsd"/>
            <xs:import namespace="http://iec.ch/TC57/2011/schema/message"
                schemaLocation="../xsd/http-iec-ch-TC57-2011-schema-message.xsd"/>
        </xs:schema>
    </types>
    <message name="msgRequestMessage">
        <part name="parameter" element="msg:RequestMessage"/>
    </message>
    <message name="msgResponseMessage">
        <part name="parameter" element="msg:ResponseMessage"/>
    </message>
    <message name="msgFaultMsg">
        <part name="msgFaultMessage" element="msg:FaultMessage"/>
    </message>
    <portType name="port_TFEDI_type">
        <operation name="request">
            <input message="wss:msgRequestMessage"/>
            <output message="wss:msgResponseMessage"/>
            <fault name="msgFaultMessage" message="wss:msgFaultMsg"/>
        </operation>
    </portType>
    <binding name="binding_TFEDI" type="wss:port_TFEDI_type">
        <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="request">
            <soap12:operation soapActionRequired="false" style="document"/>
            <input>
                <soap12:body use="literal"/>
            </input>
            <output>
                <soap12:body use="literal"/>
            </output>
            <fault name="msgFaultMessage">
                <soap12:fault name="msgFaultMessage" use="literal"/>
            </fault>
        </operation>
    </binding>
    <service name="ServiceEME">
        <port name="Service_EME_Port" binding="wss:binding_TFEDI">
            <soap12:address location="http://example.com/WebService_EME/Service_EME"/>
        </port>
    </service>
</definitions>

这项服务运行得很好,但我不知道如何避免这个标签


谢谢

头是SOAP消息中的必填字段,必须是信封下的第一个元素。它也必须是合格的。客户端需要按原样处理此问题。

这是不正确的。header元素是可选的。