Datamember反序列化问题 [英] Datamember deserialization issue

查看:222
本文介绍了Datamember反序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我正在尝试使用BasicHttpBinding的WCF服务。我的客户端是非.Net客户端。

我从客户端收到以下SOAP消息(使用 OperationContext .Current.RequestContext.RequestMessage.ToString())捕获

--------------------------------
< soap:Envelope xmlns:soap = " http://schemas.xmlsoap.org/soap/envelope/ ">
< s:标题xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/ " >
< To s:mustUnderstand =" 1" xmlns =" http://schemas.microsoft.com/ws/2005/05/addr < br> essing / none"> http:// localhost:4000 / Service1< / To>
< Action s:mustUnderstand =" 1" xmlns =" http://schemas.microsoft.com/ws/2005/05/
寻址/无"> http://tempuri.org/IService1/CompositeArgument< / Action>
< / s:Header>
< soap:Body>
< CompositeArgument xmlns =" http://tempuri.org/ ">
< value1>
< Server> xx< / Server>
<密码> xx< /密码>
<用户名> xx< /用户名>
< / value1>
< / CompositeArgument>
< / soap:Body>结果,与LT; /皂:信封>结果,--------------------------------结果<无线电通信>调用的方法是

int
IService1 .CompositeArgument( StructType value1)

和StructType定义为
-------------------------- ------


[ DataContr行为]


public struct StructType


{


string userName;


字符串密码;


字符串服务器;


[ DataMember ]


public string 用户名


{


get { return userName; }


set {userName = value ; }


}


[ DataMember ]


public string 密码


{


获取 {返回密码; }


set {password = value ; }


}


[ DataMember ]


public string 服务器


{


获取 {返回服务器; }


set {server = value ; }


}


}

--------------------- -----------
WCF无法反序列化此消息。我在结构成员中看到空值。

但是当我使用相同的I方法使用WCf客户端时它工作正常。这是WCF客户端的消息。

--------------------------------
< ; s:信封xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/ " ;>
< s:Header>
< To s:mustUnderstand =" 1" xmlns =" http://schemas.microsoft.com/ws/2005/05/addr < br> essing / none"> http:// localhost:4000 / Service1< / To>
< Action s:mustUnderstand =" 1" xmlns =" http://schemas.microsoft.com/ws/2005/05/
寻址/无"> http://tempuri.org/IService1/CompositeArgument< / Action>
< / s:Header>
< s:Body>
< CompositeArgument xmlns =" http://tempuri.org/ ">
< value1 xmlns:a =" http://schemas.datacontract.org/2004/07/ " xmlns:i =
" http://www.w3.org/2001/XMLSchema-instance ">
< a:服务器> xx< / a:服务器>
< a:密码> xx< / a:密码>
< a:用户名> xx< / a: UserName>
< / value1>
< / CompositeArgument>
< / s:Body>
< / s:Envelope>
--------- -----------------------

现在我在它们之间看到的唯一区别是value1及其成员的命名空间。

如何指定WCF基础设施来构建此模式?

解决方案

您可以将问题重定向到此论坛吗?

http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=118&SiteID= 1 搜索结果,谢谢!结果,克里斯

Hi

I am trying to use WCF service with BasicHttpBinding. My client is a non .Net  client.

I receive following SOAP messge from client (captured using OperationContext.Current.RequestContext.RequestMessage.ToString())

--------------------------------
 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addr
essing/none">http://localhost:4000/Service1</To>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/
addressing/none">http://tempuri.org/IService1/CompositeArgument</Action>
  </s:Header>
  <soap:Body>
    <CompositeArgument xmlns="http://tempuri.org/">
      <value1>
        <Server>xx</Server>
        <Password>xx</Password>
        <UserName>xx</UserName>
      </value1>
    </CompositeArgument>
  </soap:Body>
</soap:Envelope>
--------------------------------

The method that is called is

int
IService1.CompositeArgument(StructType value1)

and StructType is defined as 
--------------------------------

[DataContract]

public struct StructType

{

    string userName;

    string password;

    string server;

    [DataMember]

    public string UserName

    {

        get { return userName; }

        set { userName = value; }

    }

    [DataMember]

    public string Password

    {

        get { return password; }

        set { password = value; }

    }

    [DataMember]

    public string Server

    {

        get { return server; }

        set { server = value; }

    }

}

--------------------------------
Some how WCF is unable to deserialize this message. I see null values in structure memebers.

But when I use a WCf client using same I method it works fine. Here is message in with WCF client.

--------------------------------
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addr
essing/none">http://localhost:4000/Service1</To>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/
addressing/none">http://tempuri.org/IService1/CompositeArgument</Action>
  </s:Header>
  <s:Body>
    <CompositeArgument xmlns="http://tempuri.org/">
      <value1 xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:i=
"http://www.w3.org/2001/XMLSchema-instance">
        <a:Server>xx</a:Server>
        <a:Password>xx</a:Password>
        <a:UserName>xx</a:UserName>
      </value1>
    </CompositeArgument>
  </s:Body>
</s:Envelope>
--------------------------------

Now only difference that I see between them is namespace on value1 and its members.

How can specify WCF infrastucture to ingore this schema?

解决方案

Can you redirect your question to this forum?

http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=118&SiteID=1

Thanks!
-Chris


这篇关于Datamember反序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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