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

时间:2019-08-28 03:17:49

标签: angular web-services soap wsdl

我正在使用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>

我不确定我是否能为肥皂客户获得正确的操作/电话。任何帮助表示赞赏。谢谢!

2 个答案:

答案 0 :(得分:0)

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

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

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

答案 1 :(得分:0)

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

不应直接从URL调用此文件。这在ngx-soap模块的说明中进行了说明(请参见以下参考资料): -https://gitlab.com/oldster189/ngx-soap -https://www.npmjs.com/package/ngx-soap

顺便说一句,

Arcturien