0
我正在尝试将在线SOAP Web服务添加到我在Visual Studio中的Web应用程序中。我尝试了几个教程,但大多数教程着重于在本地主机上创建服务器。C#ASP.Net添加在线Web服务
在我的web应用程序中,我想使用以下url从web服务中获取所有国家/地区。 http://www.webservicex.net/country.asmx?op=GetCountries
它提供了以下SOAP请求和响应。
请求
POST /country.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCountries xmlns="http://www.webserviceX.NET" />
</soap12:Body>
</soap12:Envelope>
响应
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetCountriesResponse xmlns="http://www.webserviceX.NET">
<GetCountriesResult>string</GetCountriesResult>
</GetCountriesResponse>
</soap12:Body>
</soap12:Envelope>
我如何添加Web服务引用,
在Visual Studio中,我在我的项目点击 - >添加 - >服务参考 - >高级选项卡 - >添加Web引用 - >输入Web服务的URL(http://www.webservicex.net/country.asmx)。
我的问题是如何从Web服务的国家。我尝试了几种方法,但没有成功。 如何从我的asp文件中调用服务。
你有没有尝试过使用任何其他类型的Web服务?它必须是肥皂..?你可以使用Linq的Sql Web服务..肥皂是如此当老旧和过时..'WCF的网络服务更容易 – MethodMan 2014-12-05 21:34:51
那么,我的要求说我必须使用SOAP。 – Isuru 2014-12-05 21:51:45
我知道这是你的老板想用SOAP编写的东西,因为你通过绕过'SOAP'生成有效的XML,无论如何,我认为你的问题涉及不正确地使用/实例化Web服务和/或代理 – MethodMan 2014-12-05 21:54:25