2013-12-10 32 views
3

我有一个SOAP 1.1或1.2服务,我想用它来查询Windows Phone 8应用程序的一些数据。问题是,我对如何做到这一点一无所知。发送一个SOAP请求与Windows Phone 8

SOAP请求已经提供,我根本不知道如何使用它。我尝试添加一个WebService,但我在黑暗中摸索着,因为SOAP请求是由第三方提供的,很少或没有文档,很少或根本没有可能获得任何文档。

我粘贴了下面的SOAP请求。我需要基本的一步一步的指导,了解如何使用它并获得某种响应。

POST /RTPIService.asmx HTTP/1.1 
Host: rtpi.sample.servers.com 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://testsite.com/GetRealTimeStopData" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <GetRealTimeStopData xmlns="http://testsite.com/"> 
     <stopId>int</stopId> 
     <forceRefresh>boolean</forceRefresh> 
    </GetRealTimeStopData> 
    </soap:Body> 
</soap:Envelope> 

回答

0

按照以下步骤使用SOAP服务

-- Create a new project or Open Your Project. 
-- Right-click on the Project name and click on "Add Service Reference"... 
    Then provide address as "http://testsite.com/RTPIService.asmx" and click Go. 
-- Once service information is downloaded, provide Namespace something like 
    "MyRTPIService" at the bottom and click Ok. 

现在,您的代理类应该准备好。
转到您的Mainpage.xaml.cs并键入'MyRTPIService'。你应该可以得到SOAP服务提供的所有服务的类的列表。

如果你明白了,然后尝试调用该类的合适方法。

有关示例,

MyRTPIServiceClient client = new MyRTPIServiceClient(); 
client.GetRealTimeStopDataCompleted += new EventHandler<GetRealTimeStopDataCompletedEventArgs>(client_GetRealTimeStopDataCompleted); 
client.GetRealTimeStopDataAsync(); 

此外,定义的client_GetRealTimeStopDataCompleted

好运一个事件处理程序!!

+0

@irldev忘了,你所做的一切,并按照上面的步骤,并将它们与您的服务。有用 !! – nkchandra

+0

我知道如何添加服务,问题是我似乎在返回错误时收到错误,但我看不到错误是什么。 – irldev

1

只需按照波纹管的步骤

第一步:通过添加引用右键单击添加服务引用。

第二步:现在放在服务引用,然后按一下按钮,您的Web服务的链接,并添加服务引用的命名空间 enter image description here

第三步:出版社去布顿将采取autometically网络的所有方法服务

现在,在你的CS添加娄代码文件,其例如

WhatsupServices.WhatsUpServiceSoapClient ws = new WhatsupServices.WhatsUpServiceSoapClient(); 
ws.ContactUsJSONCompleted += ws_ContactUsJSONCompleted; 
ws.ContactUsJSONAsync(txtContactUsName.Text, txtContactUsPhone.Text, txtContactUsEmail.Text, txtContactUsComment.Text); 

第六步:现在genrate您resopnce方法

void ws_ContactUsJSONCompleted(object sender, dynamic e) 
     { 
      if (e.Error != null) 
      { 
       MessageBox.Show(LogIn.NetworkBusyMsg, LogIn.MsgHdr, MessageBoxButton.OK); 
       busyIndicator.IsRunning = false; 
      } 
      else 
      { 
       busyIndicator.IsRunning = false; 
       string Result = e.Result; 
       JObject obj = JObject.Parse(Result); 
       string ResultCode = (string)obj["ResultCode"]; 
       string ResponceMessage = (string)obj["ResponseMessage"]; 

       if (ResultCode == "1") 
       { 
        MessageBox.Show("Thank you for your message. We'll get back to you soon.", LogIn.MsgHdr, MessageBoxButton.OK); 
        NavigationService.GoBack(); 
       } 
       else 
       { 

       } 
      } 
     } 

希望它会帮助你。

如果任何查询比评论这儿过得无线本地环路帮你

+0

谢谢。 我正在取得一些进展,但显然这是返回的类型,虽然我不知道该怎么处理它或如何处理它: – irldev

+0

HTTP/1.1 200 OK Content-Type:application /肥皂+ xml的; charset = utf-8 内容长度:长度 <?xml version =“1.0”encoding =“utf-8”?> xmlxml irldev

+0

首先必须幅服务网址?...如果是,请将此网址放入服务参考地址栏,并根据您的说服给服务名称...如果有任何混淆让m é知道....忽略内容类型和所有这些东西 – MansinhDodiya