Soapサーバーを作成する必要がありますが、テスト目的でのみ作成する必要があります。 私の石鹸クライアントは実際の石鹸サービスで動作しますが、私のものでは動作しません。 index.jsとserver.jsは同じフォルダレベルにあります。ノード・ソープ・クライアント/サーバー・テスト
のwsdl:クライアントとの
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://corpwsdl.oneninetwo" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://corpwsdl.oneninetwo" xmlns:intf="http://corpwsdl.oneninetwo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="CFCInvocationException">
<sequence/>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="CFCInvocationException">
<wsdl:part name="fault" type="tns1:CFCInvocationException"/>
</wsdl:message>
<wsdl:message name="searchResponse">
<wsdl:part name="searchReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="searchRequest">
<wsdl:part name="xml" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="IDSearch">
<wsdl:operation name="search" parameterOrder="xml">
<wsdl:input message="impl:searchRequest" name="searchRequest"/>
<wsdl:output message="impl:searchResponse" name="searchResponse"/>
<wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="IDSearch.cfcSoapBinding" type="impl:IDSearch">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="search">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="searchRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://corpwsdl.oneninetwo" use="encoded"/>
</wsdl:input>
<wsdl:output name="searchResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://corpwsdl.oneninetwo" use="encoded"/>
</wsdl:output>
<wsdl:fault name="CFCInvocationException">
<wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://corpwsdl.oneninetwo" use="encoded"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="IDSearch">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Main ID Search Web Service </wsdl:documentation>
<wsdl:port binding="impl:IDSearch.cfcSoapBinding" name="IDSearch.cfc">
<wsdlsoap:address location="http://localhost:8001/exp?wsdl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
インデックス:
var url = 'http://localhost:8001/exp';
var options = {
disableCache: true,
escapeXML: true,
envelopeKey: 'SOAP-ENV'
};
var args = {
xml: '<![CDATA['+xml+']]>'
//xml : '<test>hello</test>'
};
soap.createClient(url, options, function (err, client) {
client.search(args, function (err, result, body) {
if (err) {
console.log("error: ", err);
console.log("Last request: \n", client.lastRequest + "\n");
}
var parsingOptions = {
'object': true,
'sanitize': false
};
console.log("Response \n\n", body);
//var jsonResult = parser.toJson(body, parsingOptions);
//console.log(jsonResult['soapenv:Envelope']['soapenv:Body']['ns1:searchResponse']['searchReturn']['$t']);
});
});
server.js
var soap = require('soap');
var http = require('http');
var fs = require('fs');
var express = require('express');
var bp = require('body-parser');
var xmlParser = require('xml');
var app = express();
////app.use(bp.json());
console.log("Starting 192com SOAP service");
var myService = {
IDSearch : { // wsdl:service
IDSearch : { // wsdl:port
search: function (args) {
return {
status: "good"
};
}
}
}
}
var xml = require('fs').readFileSync('test/192com/192com.wsdl', 'utf8');
//body parser middleware are supported (optional)
app.use(bp.raw({type: function(){return true;}, limit: '20mb'}));
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);
});
app.get('/exp', function (req, res) {
res.set('Content-Type', 'text/xml');
res.send(xml);
});
私はローカルホストに行く:8001/EXP私はWSDL
を取得私は石鹸クライアントを実行すると私は得るこの応答:
error: { Fault:
{ faultcode: 500,
faultstring: 'Invalid XML',
detail: 'Error: Unexpected close tag\nLine: 5\nColumn: 7\nChar: >',
statusCode: 500 },
response:
応答
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /exp</pre>
</body>
だから、誰もが私のserver.jsまたはWSDLと間違って何のアイデアを持っていますか?