当我在Ionic 2中使用autopulous-angular2-soap时,我得到错误:"(void 0)不是函数"
我只是安装包,在app.modules.ts中导入并在我的app.html中导入xdom.js和xdom2jso.js
有没有人有我的实施例?
app.module.ts
.simon-container {
border: 2px solid purple;
border-radius:50%;
overflow:hidden;
}
app.html
...
import {SoapService} from "autopulous-angular2-soap/soap.service";
...
providers: [SoapService]
我还测试了将xdom和xdom2jso导入src / index.html
答案 0 :(得分:0)
下面的代码对我来说很好
输入:
let input = '<?xml version="1.0" encoding="utf-8"?> \
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> \
<soap:Body> \
<**WebMethodName** xmlns="http://tempuri.org/"> \
<_Param1_>test</_Param1_> \
<_Param2_>test2</_Param2_> \
</**WebMethodName** > \
</soap:Body> \
</soap:Envelope>';
标题:
this.headers = {
responseType: "text",
headers: new HttpHeaders()
.set('Content-Type', 'text/xml; charset=utf-8')};
Http通话: 使用http客户端
this.http.post('http://localhost/yourwebservice.asmx', this.input, this.headers)
.subscribe((response) => {
let result = new DOMParser().parseFromString(res,"text/xml").getElementsByTagName("**WebMethodName**Result")[0].innerHTML;}, (error) => {\\Error Block });