3

私はapacheaxis2を使用してWebサービスに取り組んでおり、必要なクライアントコードを生成しました。クライアントリクエストは次のようになります。

`<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.huawei.com.cn/schema/common/v2_1"
xmlns:loc="http://www.csapi.org/schema/parlayx/sms/notification_manager/v2_3/local">
<soapenv:Header>
    <RequestSOAPHeader xmlns="http://www.huawei.com.cn/schema/common/v2_1">
        <spId>35000001</spId>
        <spPassword>de96d901b3bad1db2aab76b7b0b202f2</spPassword>
        <serviceId>0003062000001100</serviceId>
        <timeStamp>20120731064245</timeStamp>
    </RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
    <loc:startSmsNotification>
        <loc:reference>
            <endpoint>>http://10.138.30.153:9080/notify</endpoint>
            <interfaceName>notifySmsReception</interfaceName>
            <correlator>1232</correlator>
        </loc:reference>
        <loc:smsServiceActivationNumber>23424
        </loc:smsServiceActivationNumber> <!--Optional: -->
        <loc:criteria>Love</loc:criteria>
    </loc:startSmsNotification>
</soapenv:Body>
</soapenv:Envelope>`

リクエストに本文メッセージを追加できましたが、soapヘッダー情報は追加できませんでした。ヘッダー情報は、リクエストの検証に必要です。生成されたクライアントコードのsoapリクエストにsoapヘッダー情報を追加するにはどうすればよいですか?

4

1 に答える 1

2

こんにちはマーティン、SDP資料はインターネットですぐに利用できませんが、フォローしてみてください。

    OMFactory fac = OMAbstractFactory.getOMFactory();
    SOAPFactory sfac = OMAbstractFactory.getSOAP11Factory();

    OMNamespace omNs = fac.createOMNamespace(nameSpace, "ns1");

    SOAPHeaderBlock block_RequestSOAPHeader = sfac.createSOAPHeaderBlock(
    SOAPHEADER_RequestSOAPHeader, omNs);

    try
    {
        SOAPHeaderBlock block_spId = sfac.createSOAPHeaderBlock(SOAPHEADER_SPID, omNs);
        block_spId.addChild(sfac.createOMText(spId));

        String md_password = md5Digest(spId, spPassword, timeStamp);
        SOAPHeaderBlock block_spPassword = sfac.createSOAPHeaderBlock(SOAPHEADER_SPPASSWORD, omNs);
        block_spPassword.addChild(sfac.createOMText(md_password));

        SOAPHeaderBlock block_timeStamp = sfac.createSOAPHeaderBlock(SOAPHEADER_TIMESTAMP, omNs);
        block_timeStamp.addChild(sfac.createOMText(timeStamp));

        SOAPHeaderBlock block_serviceId = sfac.createSOAPHeaderBlock(SOAPHEADER_SERVICEID, omNs);
        block_serviceId.addChild(sfac.createOMText("your text"));


        SOAPHeaderBlock block_linkId = sfac.createSOAPHeaderBlock(SOAPHEADER_LINKID, omNs);
        block_linkId.addChild(sfac.createOMText(linkID));

        SOAPHeaderBlock block_OA = sfac.createSOAPHeaderBlock(SOAPHEADER_OA, omNs);
        block_OA.addChild(sfac.createOMText(OA));

        SOAPHeaderBlock block_FA = sfac.createSOAPHeaderBlock(SOAPHEADER_FA, omNs);
        block_FA.addChild(sfac.createOMText(FA));

        block_RequestSOAPHeader.addChild(block_spId);
        block_RequestSOAPHeader.addChild(block_spPassword);
        block_RequestSOAPHeader.addChild(block_serviceId);
        block_RequestSOAPHeader.addChild(block_timeStamp);
        block_RequestSOAPHeader.addChild(block_linkId);
        block_RequestSOAPHeader.addChild(block_OA);
        block_RequestSOAPHeader.addChild(block_FA);


        /*
         *
         *  <soapenv:Header>
         *    <ns1:RequestSOAPHeader xmlns:ns1="http://www.xxxxxxxx.xxxxxx.xxxxxx/common/v2_1">
         *      <ns1:spId>your spid</tns:spId>
         *      <ns1:spPassword>your password</tns:spPassword>
         *      <ns1:timeStamp>your timestamp</tns:timeStamp>
         *      <ns1:linkId>your linkid</tns:linkId>
         *      <ns1:OA>tel:your msisdn1</tns:OA>
         *      <ns1:FA>tel:msisdn1</tns:FA>
         *    </ns1:RequestSOAPHeader>
         *  </soapenv:Header>
         */

        serviceClient.addHeader(block_RequestSOAPHeader);
于 2013-04-23T14:10:13.807 に答える