简体   繁体   English

WCF中的Android Soap Request

[英]Android Soap Request in WCF

How to request this xml in Soap Android for WCF. 如何在Soap Android for WCF中请求此xml。 This is from WCF Test Client 这是从WCF测试客户端

<LoginNew xmlns="http://192.168.10.60/Services/">
  <Username xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Password i:nil="true" />
    <Username i:nil="true" />
    <VersionCode>0</VersionCode>
  </Username>
</LoginNew>
</s:Body>

i tried this already but no hope . 我已经尝试过了,但是没有希望。 its return null in WCF 在WCF中其返回null

    SoapObject request = new SoapObject(NAMESPACE, "LoginNew");
    SoapObject UsernamePassword = new SoapObject();
    UsernamePassword.addProperty("Username", "arlind");
    UsernamePassword.addProperty("Password", "arlind");
    request.addSoapObject(UsernamePassword);

    <s:Body>

My Wcf code: 我的Wcf代码:

    [OperationContract]
    [WebInvoke(Method = "POST",
               RequestFormat = WebMessageFormat.Json,
               ResponseFormat = WebMessageFormat.Json,
               BodyStyle = WebMessageBodyStyle.Bare,
               UriTemplate = "/LoginNew")]
    string LoginNew(UsernamePassword Username);



    public class UsernamePassword
    {
    [DataMember]
    public string Username { get; set; }
    [DataMember]
    public string Password { get; set; }
    [DataMember]
    public int VersionCode { get; set; }

    }

You're defining that the Content-type accepted by your WCF endpoint is application/Json here 您正在定义WCF终结点接受的Content-type是application / Json

    RequestFormat = WebMessageFormat.Json

so probably start by changing it to WebMessageFormat.Xml 所以可能首先将其更改为WebMessageFormat.Xml

Secondly, I believe that in order for your WCF service to accept SOAP messages, you'll also have to have your service configured for basicHttpBinding for SOAP 1.1 or wsHttpBinding for SOAP 1.2 其次,我相信为了使WCF服务能够接受SOAP消息,还必须将服务配置为针对SOAP 1.1的basicHttpBinding或针对SOAP 1.2的wsHttpBinding

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM