我嘗試使用node-soap製作帶有node.js的soap-server。 我有喜歡的WSDL如何開始使用node-soap
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://localhost:8000/wsdl">
</port>
</service>
</definitions>
和我的代碼
var http = require('http');
var soap = require('soap');
var helloService = {
Hello_Service: {
Hello_Port: {
SayHelloRequest: function(args) {
return {
firstName: args.name
};
}
}
}
}
var xml = require('fs').readFileSync('HelloService.wsdl', 'utf8'),
server = http.createServer(function(request,response) {
response.end("404: Not Found: "+request.url)
});
server.listen(8000);
soap.listen(server, '/wsdl', helloService, xml);
,我把他們放在同一個目錄,但遇到錯誤
/nodejs_ws_demo/node_modules/soap/lib/wsdl.js:937 拋出新的錯誤(p.getError()); ^ 錯誤:不匹配的標籤
如何解決該問題。
你是如何創建wsdl的?你自己寫了嗎?你知道是否有可能用節點生成這個? –
我從某處教程複製。 –