在Java wsdl客户端的标头中启用安全标记

时间:2019-06-21 05:05:41

标签: java soap netbeans wsdl ws-security

我已连接到外部wsdl,现在正尝试使用NetBeans中的Java应用程序发送消息并接收响应。

发送请求后,我收到一条错误消息,提示“安全处理器无法在消息中找到安全标头。 ' 而且我正在尝试启用消息中的安全性和时间戳,到目前为止还算不上运气。

到目前为止,我已经尝试过使用诸如RespectBindingFeature()和Addressingfeatures()之类的WebServiceFeatures,并尝试将标签手动插入其中,但这不是一个好习惯,而且还不如其他一些小实验。

我的请求如下:

            QName client = new QName("http://IVerification/VerifyDocument", "SecureWSHttpBinding_IVerification", "Https");

VerificationServiceBus service = new VerificationServiceBus();
IVerification port = service.getHttps(new AddressingFeature(true), new RespectBindingFeature(true));


            //request and input starts here
Request request = new Request();

            // Setting values to send over
                request.setFamilyName(familyName);
                request.setGivenName(givenName);

            System.out.println("Result = "); //works up to here 

            VerificationResponse result = port.verifyDocument(request);
            //.getVerificationResultCode();
            System.out.println("Result = " + result.getVerificationResultCode());

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

我的SOAPEnvelope中的Header标签如下:

    <To xmlns="http://www.w3.org/2005/08/addressing">https://test.com.au:19443/Bus/VerificationServiceBus.svc/Https</To><Action xmlns="http://www.w3.org/2005/08/addressing">http://DVS/Common/2014/06/Contract/Service/Manager/IVerification/VerifyDocument</Action><ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
        <Address>
        http://www.w3.org/2005/08/addressing/anonymous
    </Address>
    </ReplyTo>
        <FaultTo xmlns="http://www.w3.org/2005/08/addressing">
        <Address>
        http://www.w3.org/2005/08/addressing/anonymous
    </Address>
    </FaultTo>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing">
        uuid:89592e0e-c7e4-46ab-8852-1651651345</MessageID>
</S:Header> 

虽然成功的人看起来像:

        <a:Action s:mustUnderstand="1">http://IVerification/VerifyDocument</a:Action>
        <a:MessageID>urn:uuid:5ddffdda99-5a0d-9567-bb23-635465435</a:MessageID>
        <a:ReplyTo>
            <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
        <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo2/NnP1g9fROISJHS25vYClYcJJJJ0QrfpWi6zkFUTFDIVBOI/7z+nHYxfU2pLo4cij3myeGIYGIY</VsDebuggerCausalityData>
        <a:To s:mustUnderstand="1" u:Id="_1">https://test.com.au:19443/Bus/VerificationServiceBus.svc/Https</a:To>
        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <u:Timestamp u:Id="_0">
                <u:Created>2018-10-23T23:53:41.651Z</u:Created>
                <u:Expires>2018-10-23T23:58:41.651Z</u:Expires>
            </u:Timestamp>
            <o:BinarySecurityToken>
                <!-- Removed-->
            </o:BinarySecurityToken>
            <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
                <SignedInfo>
                    <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
                    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
                    <Reference URI="#_0">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
                        <DigestValue>dbwqisdygI98nEEw/rUCbvtazU=</DigestValue>
                    </Reference>
                    <Reference URI="#_1">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
                        <DigestValue>pNOIUGUInMLeJ+zswIUYFGIYG=</DigestValue>
                    </Reference>
                </SignedInfo>
                <SignatureValue><!-- Removed --></SignatureValue>
                <KeyInfo>
                    <o:SecurityTokenReference>
                        <o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-385f01dc-fd05-459f-8da9-d32b3310cdd2-1"></o:Reference>
                    </o:SecurityTokenReference>
                </KeyInfo>
            </Signature>
        </o:Security>
    </s:Header>

我希望得到一个简单的结果,例如“ Y”或“ N”,但仍然不能启用我的安全标签。

任何帮助将不胜感激。

谢谢

0 个答案:

没有答案