有关在C#桌面应用程序中使用php Web服务的问题 [英] Problem regarding consuming php web service in c# Desktop application

查看:218
本文介绍了有关在C#桌面应用程序中使用php Web服务的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发c#桌面应用程序,并使用在尝试使用该应用程序时在php应用程序中开发的webservies。我只是添加该Web服务的Web参考,并尝试通过以下代码访问

I am developing a c# desktop application and using a webservies which is developed in a php application when i try to consume that application. I just add web REference of that web service and try to access throught the following code

WebReference.TestWSDL pdl = new testingApp.WebReference.TestWSDL();
string copy = pdl.verify("testing");

当我尝试调用方法verify时会引发错误。错误是

it throws the error when i try to call the method verify. the error is

可能的SOAP版本不匹配:信封名称空间 http://schemas.xmlsoap.org/wsdl/ 是意外的。期望 http://schemas.xmlsoap.org/soap/envelope/

Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.

和Web服务链接就像

http://171.139.101.12/code/index.php/webservice/wsdl

推荐答案

您遇到的错误通知您,当您调用Web服务时,将获得该服务的WSDL(Web服务定义语言)-这是描述服务功能,但实际上不能用于调用服务。通常,您可以通过在服务URI后面附加?wsdl或 wsdl来访问WSDL。

The error you are encountering is informing you that when you invoke the webservice, you are being given the WSDL (Web Service Definition Language) for the service - this is the metadata that describes the service functions, but cannot actually be used to invoke the service. Usually, you access the WSDL by appending either "?wsdl" or "wsdl" to the service URI.

您要使用的Web服务包含两个元素。

There are two elements to the webservice you are attempting to consume.

实际服务位于:

http://171.139.101.12/代码/index.php/webservice

描述它的元数据位于Visual Studio通过wsdl.exe用来生成代理的位置:

The metadata describing it, which Visual Studio via wsdl.exe used to generate a proxy, resides here:

http://171.139.101.12/code/index.php/webservice/wsdl

您需要编辑Web参考的属性并适当地更新地址。另外,您可以更改pdl变量的属性,并在代码中更改端点。

You need to edit the properties of the Web Reference and update the address appropriately. Alternatively, you can alter the properties of the pdl variable, and change the endpoint in code.

这篇关于有关在C#桌面应用程序中使用php Web服务的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆