const soap = require("soap");
const http = require("http");
const webservice = {};
webservice.wsdl = `
<?xml version="1.0"?>
<wsdl:definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/stockquote.xsd" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="WriteObjectRequest">
<xsd:complexType>
<xsd:all>
<xsd:element name="xtlb" type="string"/>
<xsd:element name="jkid" type="string"/>
<xsd:element name="xmlDoc" type="string"/>
<xsd:element name="yhdh" type="string"/>
<xsd:element name="mm" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="WriteObjectResponse">
<xsd:complexType>
<xsd:all>
<xsd:element name="WriteObjectOutResult" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="TradePriceSubmit">
<xsd:complexType>
<xsd:all>
<xsd:element name="xtlb" type="string"/>
<xsd:element name="jkid" type="string"/>
<xsd:element name="xmlDoc" type="string"/>
<xsd:element name="yhdh" type="string"/>
<xsd:element name="mm" type="string"/>
<xsd:element name="WriteObjectOutResult" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="valid" type="boolean"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="WriteObjectInput">
<wsdl:part name="body" element="xsd1:WriteObjectRequest"/>
</wsdl:message>
<wsdl:message name="WriteObjectOutput">
<wsdl:part name="body" element="xsd1:WriteObjectResponse"/>
</wsdl:message>
<wsdl:portType name="StockQuotePortType">
<wsdl:operation name="WriteObject">
<wsdl:input message="tns:WriteObjectInput"/>
<wsdl:output message="tns:WriteObjectOutput"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="WriteObject">
<soap:operation soapAction="http://example.com/WriteObject"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
<soap:address location="http://localhost:8001/HBService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>`;
webservice.server = null;
webservice.service = {
StockQuoteService: {
StockQuotePort: {
WriteObject: async (args, cb, soapHeader) => {
const myServer = new MyServer(ctx);
let res = await myServer.receiveData(args);
return { WriteObjectOutResult: res };
}
}
}
};
webservice.server = http.createServer(function (request, response) {
response.end("404: Not Found: " + request.url);
});
webservice.server.listen(8001, null, null, function () {
webservice.soapServer = soap.listen(webservice.server, "/HBService", webservice.service, webservice.wsdl);
webservice.baseUrl = "http://" + webservice.server.address().address + ":" + webservice.server.address().port;
if (webservice.server.address().address === "0.0.0.0" || webservice.server.address().address === "::") {
webservice.baseUrl = "http://127.0.0.1:" + webservice.server.address().port;
}
});