Node JS中的Soap Webservice

时间:2016-10-21 06:28:49

标签: node.js soap wsdl soapui

我正在尝试使用npm模块soap在节点js中构建soap webservice。我正在使用提到的soap.listen函数在节点js中启动soap服务器。我包含的wsdl文件如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8100/api/orderStatusWsdl" xmlns="http://localhost:8100/api/orderStatusWsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <wsdl:message name="receiveOrderStatusRequest">
        <wsdl:part name="a" type="xs:string"/>
        <wsdl:part name="b" type="xs:string"/>
    </wsdl:message>
    <wsdl:message name="receiveOrderStatusResponse">
        <wsdl:part name="orderStatusResponse" type="xs:string"/>
    </wsdl:message>
    <wsdl:portType name="orderStatusPort">
        <wsdl:operation name="receiveOrderStatus">
            <wsdl:input message="receiveOrderStatusRequest"/>
            <wsdl:output message="receiveOrderStatusResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="orderStatusBinding" type="orderStatusPort">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="receiveOrderStatus">
            <soap:operation soapAction="receiveOrderStatus"/>
            <wsdl:input>
                <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="orderStatusService">
        <wsdl:port binding="orderStatusBinding" name="orderStatus">
            <soap:address location="http://localhost:8100/api/orderStatusWsdl"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

节点js代码:

var orderStatusWsdlXml = fs.readFileSync(path.join(__dirname, 'soap/wsdl/myWsdl2.wsdl'), 'utf8')
var soapServer = soap.listen(server, BASE_URL + '/orderStatusWsdl', orderStatusSoapService, orderStatusWsdlXml2)

soapServer.log = function(type, data) {
    log.d('TYPE: ' + type)
    log.d('DATA: ' + JSON.stringify(data, null, 4))
}

运行节点项目后,我尝试在SOAP UI客户端中加载WSDL,我收到以下错误:

Error loading [http://localhost:8100/api/orderStatusWsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null 

我哪里错了?

0 个答案:

没有答案