NodeJS中的SOAP模块

时间:2018-02-26 02:08:02

标签: javascript node.js soap wsdl

我尝试在 NodeJS 中使用 SOAP 模块作为现有 SOAP 服务提供商的客户端,并且我正在尝试使用 SOAP 模块。挣扎......我一直得到这样的错误:

OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetCredit' and namespace 'https://api.computing.cloud.it/WsEndUser'. Found node type 'Element' with name 'GetCredit' and namespace 'https://api.computing.cloud.it/WsEndUser/jsonp'

这里是 WSDL https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl

这是我用于通话的代码:

var wsdlUrl = 'https://api.dc2.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl';
var wsSecurity = new soap.WSSecurity('ARU-XXXX', '1234xyz!');
soap.createClient(wsdlUrl,wsdlOptions, function (err, client) {
if (err) {
    console.log(err);
} else {
    client.setSecurity(wsSecurity);
    client.GetCredit({}, function (err, result) {
        if (err) {
            console.log(err);
        }
        else {
            console.log(result);
        }
    });
  }
});

我尝试添加明确的覆盖:

var wsdlOptions = { overrideRootElement: {
    namespace: 'myns',
    xmlnsAttributes: [{
       name: 'xmlns:myns',
       value: 'https://api.computing.cloud.it/WsEndUser/jsonp'
       }]
    }
};

这是我在回答的内容:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <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-03-01T10:33:26.911Z</u:Created>
                <u:Expires>2018-03-01T10:38:26.911Z</u:Expires>
            </u:Timestamp>
        </o:Security>
    </s:Header>
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault
            </faultcode>
            <faultstring xml:lang="it-IT">
                Error in deserializing body of request message for operation \'GetCredit\'.OperationFormatter encountered an invalid Message body. Expected to find node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser\'. Found node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser/jsonp\'
            </faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <HelpLink i:nil="true"/>
                <InnerException>
                    <HelpLink i:nil="true"/>
                    <InnerException i:nil="true"/>
                        <Message>
                            OperationFormatter encountered an invalid Message body. Expected to find node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser\'. Found node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser/jsonp\'
                        </Message>
                        <StackTrace>
                           at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)&#xD;\n at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)&#xD;\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
                        </StackTrace>
                        <Type>
                            System.Runtime.Serialization.SerializationException
                        </Type>
                    </InnerException>
                        <Message>
                            Error in deserializing body of request message for operation \'GetCredit\'. OperationFormatter encountered an invalid Message body. Expected to find node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser\'. Found node type \'Element\' with name \'GetCredit\' and namespace \'https://api.computing.cloud.it/WsEndUser/jsonp\'
                        </Message>
                        <StackTrace>   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)&#xD;\n   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
                        </StackTrace>
                        <Type>
                            System.ServiceModel.CommunicationException
                        </Type>
                    </ExceptionDetail>
                </detail>
            </s:Fault>
        </s:Body>
    </s:Envelope>

任何帮助?

0 个答案:

没有答案