You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Vue.js中调用Delphi开发的SOAP WebService的sum方法?

Vue调用Delphi WebService的URL填写说明

结论

webservice_url 可以填写以下两个地址中的任意一个:

  • http://127.0.0.1:8080/soap/iservice1(你直接给出的服务地址)
  • http://localhost:8080/soap/Iservice1(WSDL文档中<address>标签指定的地址)

这两个地址在本地环境下完全等价,因为localhost是127.0.0.1的域名映射。

补充完整请求示例

由于该WebService是RPC/encoded风格的SOAP服务,请求需要符合SOAP规范,完整的axios调用代码如下:

const webservice_url = 'http://127.0.0.1:8080/soap/iservice1';
// 构造符合SOAP规范的请求XML
const data_to_send = `<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:service1Intf-Iservice1">
  <soap:Body>
    <urn:sum>
      <a>Hello</a>
      <b>World</b>
    </urn:sum>
  </soap:Body>
</soap:Envelope>`;

axios({
  method: 'post',
  url: webservice_url,
  data: data_to_send,
  headers: {
    'Content-Type': 'text/xml; charset=utf-8',
    'SOAPAction': 'urn:service1Intf-Iservice1#sum' // 对应WSDL中sum操作的soapAction
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});

内容的提问来源于stack exchange,提问作者Ham

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 01:55:24