Soap请求使用Node.Js

我必须连接到一些使用SOAP 1.1 standard服务,并且用C#和Java编写的类向我发送文档。 我不能build立连接,它给了我错误的400错误的请求。 我从来没有使用SOAP请求的经验,也没有C#和Java的经验。 我可以放在这里是这个代码

 const wsse = require('wsse'); const token = wsse({ username: config.get('serviceToConnect.auth.testUsername'), password: config.get('serviceToConnect.auth.testPassword') }); // eg 'UsernameToken Username="bob", PasswordDigest="quR/EWLAV4xLf9Zqyw4pDmfV9OY=", Nonce="d36e316282959a9ed4c89851497a717f", Created="2003-12-15T14:43:07Z"' request.post( { url: config.get('serviceToConnect.url.sessionRequestUrl'), body: new Buffer(bodyRequest), encoding: 'utf-8', headers: { 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': bodyRequest.length, 'Security': token.getWSSEHeader(), 'SOAPAction': 'urn:#AuthenticateUser' } }) 

这是wsdl文件。 我想我需要提取SOAP操作URL。 但是这是什么? PS。 我用www.myService.com取代了原来的Url

 <?xml version="1.0" encoding="UTF-8"?> <definitions name="SessionRequestWSDL" targetNamespace="http://www.myService.com/webservices/SessionRequest" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.myService.com/webservices/SessionRequest" xmlns:ns="http://www.myService.com/webservices/SessionRequest" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <xsd:schema targetNamespace="http://www.myService.com/webservices/SessionRequest"> <xsd:import namespace="http://www.myService.com/webservices/SessionRequest" schemaLocation="../schema/SessionRequest.xsd"/> </xsd:schema> </types> <message name="SessionRequestOperationRequest"> <part name="part1" element="tns:SessionRequest"/> </message> <message name="SessionRequestOperationResponse"> <part name="part1" element="tns:SessionRequest-Response"/> </message> <portType name="SessionRequestPortType"> <operation name="SessionRequest"> <input name="input1" message="tns:SessionRequestOperationRequest"/> <output name="output1" message="tns:SessionRequestOperationResponse"/> </operation> </portType> <binding name="SessionRequestBinding" type="tns:SessionRequestPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="SessionRequest"> <soap:operation soapAction="urn:#AuthenticateUser"/> <input name="input1"> <soap:body use="literal"/> </input> <output name="output1"> <soap:body use="literal"/> </output> </operation> </binding> <service name="SessionRequestService"> <port name="SessionRequestPort" binding="tns:SessionRequestBinding"> <!-- NOTICE: The service location URL below is NOT VALID Valid service URLs will be provided by your MyService.Net Project Manager --> <soap:address location="http://localhost/SessionRequestService/SessionRequestPort"/> </port> </service> </definitions> 

主要问题 – 我发送正确的SoapActionurl。 另外,他们说我需要发送WS来回地址,他们会提供给我,但他们没有。 对于From我猜我的域名,并且是URL服务? 这是应该去头或XML身体请求的东西?

这是他们的代码的一部分,它使用他们在Java中编写的库来实现Web服务。

 public class Main { public static void main(String[] args) { BigInteger applicationID = BigInteger.valueOf(12345); UserModel userModel = null; UserType user = null; // Get an instance of the webservice client service // This library will expect the wsdl file to be available at /xml-resources/web-service-references/SessionRequest/wsdl/SessionRequest.wsdl at runtime (where the root directory is the root of the packaged java classes ) // The associated schemas will also need to be available in their correct relative locations to the wsdl file. // // Alternately, set the location of the wsdl file at runtime using the setLocalWSDL() method. // Refer to the WebserviceClient class javadoc for details. SessionRequestService client = WebserviceClient.create(SessionRequestService.class); SessionRequestPortType port = client.getSessionRequestPort(); //set webservice endpoint and add a username token WebserviceClient.setEndpoint(port, new URL("http://service.url/that/will/be/provided")); WebserviceClient.setUsernameToken(port, new UsernameToken("some-id", "the-password")); try { ...