在离子2中使用AutoProulus-angular2-soap时出错
当我在Ionic 2中使用autopulous-angular2-soap时,我得到一个错误:“(void 0)不是一个函数” 我只需要安装包,在app.modules.ts中导入,并在我的app.html中导入xdom.js和xdom2jso.js 有没有人能为我提供一个实现示例 app.module.ts在离子2中使用AutoProulus-angular2-soap时出错,soap,ionic2,Soap,Ionic2,当我在Ionic 2中使用autopulous-angular2-soap时,我得到一个错误:“(void 0)不是一个函数” 我只需要安装包,在app.modules.ts中导入,并在我的app.html中导入xdom.js和xdom2jso.js 有没有人能为我提供一个实现示例 app.module.ts ... import {SoapService} from "autopulous-angular2-soap/soap.service"; ... providers: [Soap
...
import {SoapService} from "autopulous-angular2-soap/soap.service";
...
providers: [SoapService]
app.html
<script src="../../node_modules/autopulous-angular2-soap/vendor/autopulous-xdom/xdom.js"></script>
<script src="../../node_modules/autopulous-angular2-soap/vendor/autopulous-xdom2jso/xdom2jso.js"></script>
我还做了一个测试,将导入的xdom和xdom2jso放在下面的src/index.html中,代码对我来说很好
输入:
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 });