2013-12-23 1 views
3

node-soap을 사용하여 node.js로 soap-server를 만들려고합니다. 나는이와 내가 같은 디렉토리에 넣어하지만 오류시작하는 방법 node-soap

/nodejs_ws_demo/node_modules/soap/lib/wsdl.js:937있어

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); 

<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> 

내 코드와 같은 WSDL 새 오류 발생 (p.getError()); ^ 오류 : 일치하지 않는 태그

어떻게 수정합니까?

+0

어떻게 wsdl을 만들었습니까? 너 혼자 작성 했니? 노드로 이것을 생성 할 수 있는지 알고 있습니까? –

+0

어딘가에서 자습서에서 복사 해요. –

답변

1

wsdl 파일에 오류가 있습니다. 비누 꼬리표가 닫히지 않았습니다.

<soap:address 
     location="http://localhost:8000/wsdl"/> 
2
var helloService = { 
    Hello_Service: { 
    Hello_Port: { 
     sayHello: function(args) { 
     return { 
      greeting: "Hello!!!" 
     }; 
     } 
    } 
    } 
} 

수정이 당신 코드 (당신이 코드를 잘못의 이름 방법 및 출력 매개 변수). sayHello wsdl 파일의 soapAction입니다.