肥皂要求不好,为什么?

时间:2018-07-29 21:01:50

标签: soap

这是我的请求xml代码:

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://example.org/quotations">
      <m:GetQuotation>
         <m:QuotationsName>MiscroSoft</m:QuotationsName>
      </m:GetQuotation>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我从w3c school复制了此内容。

当我使用工具(如邮递员之类的回旋镖)将此请求发送到本地服务器时,收到以下错误消息:

TypeError: Cannot read property 'description' of undefined
    at SAXParser.p.onopentag (C:\Users\nick\projects\test-soap\node_modules\soap\lib\wsdl.js:1305:27)
    at emit (C:\Users\nick\projects\test-soap\node_modules\sax\lib\sax.js:624:35)
    at emitNode (C:\Users\nick\projects\test-soap\node_modules\sax\lib\sax.js:629:5)
    at openTag (C:\Users\nick\projects\test-soap\node_modules\sax\lib\sax.js:825:5)
    at SAXParser.write (C:\Users\nick\projects\test-soap\node_modules\sax\lib\sax.js:1278:15)
    at WSDL.xmlToObject (C:\Users\nick\projects\test-soap\node_modules\soap\lib\wsdl.js:1507:5)
    at Server._process (C:\Users\nick\projects\test-soap\node_modules\soap\lib\server.js:234:21)
    at Server._processRequestXml (C:\Users\nick\projects\test-soap\node_modules\soap\lib\server.js:146:10)
    at Server._requestListener (C:\Users\nick\projects\test-soap\node_modules\soap\lib\server.js:207:19)
    at C:\Users\nick\projects\test-soap\node_modules\soap\lib\server.js:56:14
    at Layer.handle [as handle_request] (C:\Users\nick\projects\test-soap\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\nick\projects\test-soap\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\nick\projects\test-soap\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\nick\projects\test-soap\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\nick\projects\test-soap\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\Users\nick\projects\test-soap\node_modules\express\lib\router\index.js:335:12)

我的问题是怎么回事?我不知道发生了什么。

这是我的wsdl文件:

<wsdl:definitions targetNamespace="http://developer.intuit.com/">
   <wsdl:documentation>
        WebService for QBFS created using ASP.NET to troubleshoot QuickBooks WebConnector
    </wsdl:documentation>
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://developer.intuit.com/">
            <s:element name="serverVersion">
               <s:complexType/>
            </s:element>
            <s:element name="serverVersionResponse">
                <s:complexType>
                   <s:sequence>
                      <s:element minOccurs="0" maxOccurs="1" name="serverVersionResult" type="s:string"/>
                   </s:sequence>
                </s:complexType>
            </s:element>                    
        </s:schema>
    </wsdl:types>
   <wsdl:message name="nickAgeSoapIn">
      <wsdl:part name="parameters" element="tns:serverVersion"/>
   </wsdl:message>      
   <wsdl:message name="nickAgeSoapOut">
      <wsdl:part name="parameters" element="tns:serverVersionResponse"/>
   </wsdl:message>
   <wsdl:portType name="TestNickPort">
      <wsdl:operation name="nickAge">
         <wsdl:input message="tns:nickAgeSoapIn"/>
         <wsdl:output message="tns:nickAgeSoapOut"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="TestNickAgeWebServiceFSSoap" type="tns:TestNickPort">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
          <wsdl:operation name="nickAge">
            <soap:operation soapAction="http://developer.intuit.com/serverVersion" style="document"/>
                <wsdl:input>
                    <soap:body use="literal"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>           
   </wsdl:binding>
   <wsdl:service name="tns:TestNickPort">
        <wsdl:port name="TroubleshootWebServiceFSSoap" binding="tns:TestNickPort">
            <soap:address location="localhost:8001/wsdl"/>
        </wsdl:port>    
   </wsdl:service>
</wsdl:definitions>

这是我的服务器代码:

var soap = require('soap')
var http = require('http')
let url = 'https://test.developer.intuit.com/QBWC/TroubleshootWebServiceFS/Service.asmx?wsdl'
var express = require('express')
var bodyParser = require('body-parser')
var logger = require('morgan')

var myService = {
  MyService: {
      MyPort: {
          MyFunction: function(args) {
              return {
                  name: args.name
              };
          },

          // This is how to define an asynchronous function.
          MyAsyncFunction: function(args, callback) {
              // do some work
              callback({
                  name: args.name
              });
          },

          // This is how to receive incoming headers
          HeadersAwareFunction: function(args, cb, headers) {
              return {
                  name: headers.Token
              };
          },

          // You can also inspect the original `req`
          reallyDetailedFunction: function(args, cb, headers, req) {
              console.log('SOAP `reallyDetailedFunction` request from ' + req.connection.remoteAddress);
              return {
                  name: headers.Token
              };
          }
      }
  }
};

var xml = require('fs').readFileSync('./test_minimum.wsdl', 'utf8')


var app = express();
app.use(logger('dev'));
app.get('', (req, res) => res.send('Hello world'))
//body parser middleware are supported (optional)
app.use(bodyParser.raw({type: function(){return true;}, limit: '5mb'}));
app.listen(8001, function(){
    //Note: /wsdl route will be handled by soap module
    //and all other routes & middleware will continue to work
    soap.listen(app, '/wsdl', myService, xml);

    console.log('express is listening port 8001...')
});

0 个答案:

没有答案