在Windows Phone中使用基于SOAP的Web服务 [英] Consuming soap based web service in Windows Phone

查看:117
本文介绍了在Windows Phone中使用基于SOAP的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先要注意我正在调用link?wsdl web服务。我正在使用Visual Studio 2010,我已经创建了Windows Phone应用程序。



我添加了一个新的服务引用到WebService,它生成了所有类的正确办法。接下来我做的是写下波纹管代码,以便调用Web服务并获得响应。



只需注意两件事:



1. SoapUI返回正确的值。

2.相同的代码适用于Visual Studio 2010中的控制台应用程序并返回正确的字符串。





以下是代码:



First of all to note that I am calling link?wsdl web service. I am using Visual Studio 2010 and I have created Windows Phone application.

I added a New service reference to the WebService, and it generated all of the classes in a proper way. Next what I did is I wrote the bellow code in order to call web service and get the response.

Just to note two things:

1. SoapUI returns correct value.
2. The same code works on Console Application in Visual Studio 2010 and returns the correct string.


The following is code:

namespace testApp
{
public partial class MainPage : PhoneApplicationPage
{


    public MainPage()
    {
        InitializeComponent();

        WebService.ServiceClient ws = new WebService.ServiceClient();
        ws.FirstMethodCompleted += new EventHandler<FirstMethodCompletedEventArgs>(ws_getReklamaLinkCompleted);
        ws.getReklamaLinkAsync(param1, param2);


    void ws_FirstMethodCompleted(object sender, WebService.FirstMethodCompletedEventArgs e)
    {

        System.Diagnostics.Debug.WriteLine("Error is: " + e.Error);

    }
}
}



问题是Windows Phone应用程序中的此代码返回以下例外:




Well the problem is that this code in Windows Phone Application returns following exception:

Unmarshalling Error: unexpected element (uri:"http://testwebservice.portal.com/",    local:"param1"). Expected elements are <{}param1>,<{}param1>





我现在在2天内苦苦挣扎。任何人都可以告诉我为什么相同的代码适用于控制台应用程序而不是Windows Phone应用程序,它可能是什么解决方案?



我还有什么方法可以消费网络服务?



I am struggling with this well over 2 days now. Can anyone tell me why the same code works on Console application and not on Windows Phone application and what could be the solution for it?

What other ways I have to consume the web service?

推荐答案

你可以通过以下链接这可能对你有帮助。



HTTP: //blogs.msdn.com/b/netcfteam/archive/2007/02/01/why-your-netcf-apps-fail-to-call-some-web-services.aspx [ ^ ]



http://social.msdn.microsoft.com/Forums/en-US/c981593f -35f3-43bc-879d-3c59cfecb5a6 / PROBL em-consume-java-web-service-from-c?forum = netfxcompact [ ^ ]
you can go through below link this might help you .

http://blogs.msdn.com/b/netcfteam/archive/2007/02/01/why-your-netcf-apps-fail-to-call-some-web-services.aspx[^]

http://social.msdn.microsoft.com/Forums/en-US/c981593f-35f3-43bc-879d-3c59cfecb5a6/problem-consuming-java-web-service-from-c?forum=netfxcompact[^]


这篇关于在Windows Phone中使用基于SOAP的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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