Web.config与WSDL的soap:address是否需一致?及报错修复
问题解答
提供的配置信息
web.config 配置
<client> <endpoint address="http://ogr-cust-w01:90/Cust2024.asmx" binding="basicHttpBinding" bindingConfiguration="Cust2024MenuSoap" contract="Cust2024_DEVL.Cust2024MenuSoap" name="CustMenuSoap" /> </client>
WSDL 文件片段
<wsdl:service name="Cust2024Menu"> <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Cust2024DataAccess</wsdl:documentation> <wsdl:port name="CustMenuSoap" binding="tns:CustMenuSoap"> <soap:address location="http://www.cust.com:70/Cust2024.asmx" /> </wsdl:port> <wsdl:port name="Cust2024MenuSoap12" binding="tns:Cust2024MenuSoap12"> <soap12:address location="http://www.cust.com:70/Cust2024.asmx" /> </wsdl:port> </wsdl:service>
注:web.config中配置的地址为http://org-cust-w01:90/Cust2024.asmx,WSDL中对应契约Cust2024_DEVL.Cust2024MenuSoap的地址为http://www.cust.com:70/Cust2024.asmx,二者不一致。
问题1:Web.config中的endpoint address与WSDL中的soap:address是否必须保持一致?
不一定必须一致。WSDL里的soap:address是服务发布时定义的默认地址,但客户端web.config的endpoint address可以根据服务实际部署的环境修改——比如服务在测试、生产环境有不同的部署地址,客户端只需配置对应环境下可正常访问服务的有效地址即可,无需和WSDL原始地址完全匹配。核心是客户端配置的地址必须指向当前正在运行的Web服务实例。
问题2:如何修复报错「There was no endpoint listening at http://org-cust-w01:90/Cust2024.asmx that could accept the message. This is often caused by an incorrect address or SOAP action.」
这个报错说明客户端配置的地址http://org-cust-w01:90/Cust2024.asmx无法连通到服务,按以下步骤排查修复:
- 验证地址有效性:直接在浏览器或工具(如Postman)访问该地址,确认是否能打开ASMX服务页面。如果打不开,说明地址或端口错误,或者服务未启动。
- 替换为正确地址:如果
org-cust-w01:90确实不可用,将web.config中的endpoint address修改为WSDL里的http://www.cust.com:70/Cust2024.asmx(前提是该地址能正常访问),或者服务实际部署的正确地址。 - 检查网络连通性:确认客户端服务器能ping通目标服务地址,排查是否有防火墙、代理服务器拦截了请求,或者端口90未对外开放。
- 核对SOAP配置:检查
binding、bindingConfiguration和contract是否与服务端完全匹配,避免因绑定协议、配置参数不兼容导致的隐性错误。
内容的提问来源于stack exchange,提问作者Nandhini
相关产品推荐
相关产品推荐

