easySoap读取XMLStreamReader时出错

时间:2015-05-22 03:05:01

标签: node.js web-services soap

我正在使用easySoap来访问SOAP Web服务,在SoapUI中,调用有效,但不在easySoap中。它给了我

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Error reading XMLStreamReader.</faultstring></soap:Fault></soap:Body></soap:Envelope>'

现在我猜测服务是通过标准的http调用而不是SOAP调用来调用的?但我怎么能改变呢?

SoapUI中的完整肥皂调用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://dpd.com/common/service/types/Authentication/2.0" xmlns:ns1="http://dpd.com/common/service/types/ShipmentService/2.0">
<soapenv:Header>
  <ns:authentication>
     <delisId>******</delisId>
     <authToken>**********************</authToken>
     <messageLanguage>en_EN</messageLanguage>
  </ns:authentication>
</soapenv:Header>
<soapenv:Body>
  <ns1:storeOrders>
     <!--1 to 30 repetitions:-->
     <order>
        <generalShipmentData>
           <sendingDepot>0163</sendingDepot>
           <product>CL</product>
           <sender>
              <name1>dsf</name1>
              <street>sdfsf</street>
              <country>BE</country>
              <zipCode>2610</zipCode>
              <city>WILRIJK</city>
           </sender>
           <recipient>
              <name1>sdf</name1>
              <street>sdf</street>
              <country>BE</country>
              <zipCode>2890</zipCode>
              <city>sd</city>
           </recipient>
        </generalShipmentData>
         <parcels></parcels>
         <productAndServiceData>
           <orderType>consignment</orderType>
        </productAndServiceData>
     </order>
  </ns1:storeOrders>

在代码中:

var dpdRecord;
dpdSchema.findOne({}, function (err, dpd) {
    dpdRecord = dpd;

    var clientParams = {
        host: 'public-ws-stage.dpd.com',
        path: '/services/ShipmentService/V2_0/',
        wsdl: '/services/ShipmentService/V2_0/?wsdl',

        header: [{
            'delisId': delisId,
            'authToken': dpd.authToken,
            'messageLanguage': messageLanguage
        }]
    };
    var clientOptions = {
        secure: true//is https or http
    };


    //create new soap client
    var SoapClient = new easySoap.Client(clientParams, clientOptions);

    SoapClient.call({
        'method': 'storeOrders'

        ,
        'params': {
            order: {
                generalShipmentData: {
                    sendingDepot: 0163,
                    product: "CL",
                    sender: {
                        name1: "test",
                        street: "teststraat",
                        country: "DE",
                        zipCode: 1111,
                        city: "Ort"
                    },
                    recipient: {
                        name1: "tester",
                        street: "teststraat",
                        country: "DE",
                        zipCode: 1111,
                        city: "Ort"
                    }
                },
                productAndServiceData: {
                    orderType: "consignment"
                }
            }
        }

    }).done(function (res) {
            res.data        // response data as array
            res.response    // full response data (including xml)
            res.header      // response header
            console.log(res.response);
        },

        //method fail
        function (err) {
            console.log(err);
        });
});

0 个答案:

没有答案