如何使用 ngx soap 从 SOAP 服务调用操作?



我正在使用 Angular cli 8.3.0,使用 ngx-soap 调用 soap 服务。我从下面的代码中收到错误"TypeError:this.client.GetDocumentContent 不是函数"。

constructor(
private http: HttpClient,
private soap: NgxSoapService,
private messageService: MessageService) {  
this.soap.createClient('http://<ip address>/test/iEDMSWSServ.svc?wsdl').then(client => {
this.client = client;
console.log('Created client!');
})
.catch(function(error) {
console.log(error);
});      
}
(<any>this.client).GetDocumentContent(body).subscribe((res: ISoapMethodResponse) => console.log(res));

来自 wsdl..

<wsdl:message name="GetDocumentRequest">
<wsdl:part name="parameters" element="tns:GetDocumentRequest"/>
</wsdl:message>
<wsdl:message name="GetDocumentResponse">
<wsdl:part name="parameters" element="tns:GetDocumentResponse"/>
</wsdl:message>
<wsdl:message name="CreateDocumentRequest">
<wsdl:part name="parameters" element="tns:CreateDocumentRequest"/>
</wsdl:message>
<wsdl:message name="CreateDocumentResponse">
<wsdl:part name="parameters" element="tns:CreateDocumentResponse"/>
</wsdl:message>
<wsdl:portType name="IWCFFacade">
<wsdl:operation name="GetDocumentContent">
<wsdl:input wsaw:Action="http://tempuri.org/IWCFFacade/GetDocumentContent" name="GetDocumentRequest" message="tns:GetDocumentRequest"/>
<wsdl:output wsaw:Action="http://tempuri.org/IWCFFacade/GetDocumentContentResponse" name="GetDocumentResponse" message="tns:GetDocumentResponse"/>
</wsdl:operation>
<wsdl:operation name="CreateDocument">
<wsdl:input wsaw:Action="http://tempuri.org/IWCFFacade/CreateDocument" name="CreateDocumentRequest" message="tns:CreateDocumentRequest"/>
<wsdl:output wsaw:Action="http://tempuri.org/IWCFFacade/CreateDocumentResponse" name="CreateDocumentResponse" message="tns:CreateDocumentResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HttpBinding_IWCFFacade_IWCFFacade" type="tns:IWCFFacade">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetDocumentContent">
<soap:operation soapAction="http://tempuri.org/IWCFFacade/GetDocumentContent" style="document"/>
<wsdl:input name="GetDocumentRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetDocumentResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CreateDocument">
<soap:operation soapAction="http://tempuri.org/IWCFFacade/CreateDocument" style="document"/>
<wsdl:input name="CreateDocumentRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="CreateDocumentResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

我不确定我是否为 soap 客户端获得了正确的操作/调用。任何帮助,不胜感激。谢谢!

也许您可以按如下方式更改代码:

this.client.call('GetDocumentContent', body).subscribe((res: ISoapMethodResponse) => console.log(res));

参考: https://github.com/lula/ngx-soap/blob/master/src/app/app.component.ts

我认为您在代码中遗漏了一件事:必须下载 wsdl 文件并将其安装在您的资产目录中。

不应直接从 URL 调用此文件。这在ngx-soap模块的描述中有所说明(见下面的参考文献(: - https://gitlab.com/oldster189/ngx-soap - https://www.npmjs.com/package/ngx-soap

亲切

大角星

相关内容

  • 没有找到相关文章

最新更新