vue soap 调用webservice 示例
时间: 2023-11-02 07:00:07 浏览: 334
以下是一个使用 Vue.js 调用 SOAP Web Service 的示例:
1. 安装 `vue-soap`:
```
npm install vue-soap --save
```
2. 在 Vue.js 组件中导入 `vue-soap`:
```javascript
import Vue from 'vue'
import VueSoap from 'vue-soap'
Vue.use(VueSoap)
```
3. 创建一个 Vue.js 组件,并在模板中定义 SOAP Web Service 的参数:
```html
<template>
<div>
<input type="text" v-model="input" />
<button @click="callWebService">Call Web Service</button>
<div v-if="response">{{ response }}</div>
</div>
</template>
<script>
export default {
data() {
return {
input: '',
response: ''
}
},
methods: {
callWebService() {
this.$soap
.post('http://www.example.com/soap/wsdl', 'methodName', {
param1: this.input
})
.then(response => {
this.response = response
})
.catch(error => {
console.error(error)
})
}
}
}
</script>
```
在上面的示例中,`$soap.post()` 方法接受三个参数:
- `http://www.example.com/soap/wsdl`:SOAP Web Service 的 WSDL URL。
- `methodName`:要调用的 Web Service 方法的名称。
- `{ param1: this.input }`:要传递给 Web Service 方法的参数。
4. 在浏览器中打开该组件,输入参数并点击按钮,即可调用 Web Service 并显示响应结果。
阅读全文
相关推荐











