使用 Windows Phone 8 发送 SOAP 请求 [英] Sending a SOAP request with Windows Phone 8

查看:30
本文介绍了使用 Windows Phone 8 发送 SOAP 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SOAP 1.1 或 1.2 服务,我想使用它来从 Windows Phone 8 应用程序查询一些数据.问题是,我对如何做到这一点一无所知.

I have a SOAP 1.1 or 1.2 service that I want to use in order to query some data from a Windows Phone 8 app. The problem is, I haven't got the slightest notion about how to do this.

SOAP请求已经提供了,就是不知道怎么用.我已经尝试添加一个 WebService,但我有点摸不着头脑,因为 SOAP 请求是从 3rd 方提供的,几乎没有或没有文档,也几乎没有可能获得任何文档.

The SOAP request is already provided, I simply do not know how to use it. I've tried adding a WebService but I'm sort of fumbling in the dark as the SOAP request is provided from a 3rd party with little or no documentation and little or no possibility of getting any either.

我在下面粘贴了 SOAP 请求.我需要有关如何使用它并从中获得某种响应的基本分步说明.

I've pasted in the SOAP request below. I'd need basic step by step instructions about how to use this and get some sort of a response from it.

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>

推荐答案

只需按照以下步骤操作

步骤 1:通过右键单击添加引用来添加服务引用.

Step1: Add Service References by right click on add References.

Step2:现在将您的 Web 服务链接放在服务引用上,然后按 go 按钮,并添加服务引用的命名空间

Step2: Now put your web service link on Service References and press go button, And also add Namespace of service Reference

Step3:按 go 按钮它会自动执行所有的网络服务方法

Step3: Press go buton it will take autometically all method of web service

现在在您的 cs 文件中添加波纹管代码,例如

Now add bellow code in your cs file its for example

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

步骤 6:现在生成您的响应方法

 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
                {
    
                }
            }
        }

希望能帮到你.

如果有任何疑问而不是在这里评论.我会帮助你

If any query than comment here.I wll help you

这篇关于使用 Windows Phone 8 发送 SOAP 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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