xcode wcf对象作为参数

时间:2012-01-03 13:16:07

标签: xcode wcf object parameters

我正在尝试从XCODE调用具有Object作为参数而不是string或long的WCF服务。我总是使用几个服务希望有简单的参数像字符串或长,他们工作完美。但是当我使用Object作为参数时,我可以访问Windows Box上的C#服务,但参数始终是一个没有值的新C#对象。 使用的对象看起来像这样:

[DataContract]
public class MobileComplaint
{
    [DataMember]
    public long MobileComplaintID { get; set; }
    [DataMember]
    public string CaseNo { get; set; }
    [DataMember]
    public DateTime CreationDate { get; set; }
    [DataMember]
    public string CreationUser { get; set; }
    [DataMember]
    public string DaysSinceLastChange { get; set; }
    [DataMember]
    public string State { get; set; }
}

函数看起来像这样:

[OperationContract]
MobileComplaint Save(long UserID, MobileComplaint mc);

对于普通函数,我使用看起来像这样的消息:

     <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
 <SOAP-ENV:Body> 
 <OpenComplaint xmlns="http://tempuri.org/"> 
 <MobileComplaintID>3</MobileComplaintID> 
 </OpenComplaint> 
 </SOAP-ENV:Body> 
 </SOAP-ENV:Envelope>

问题现在我该如何为此消息编写参数!

第二个问题是否需要为对象添加所有参数,或者只是填写我需要的参数时就可以了。

THX寻求帮助

我总是尝试以下两种方法:

<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Body> 
<Save xmlns="http://tempuri.org/"> 
 <UserID>229001</UserID> 
<mc xmlns:a="http://schemas.datacontract.org/2004/07/Ibs.MobileDefectDetection.Vo" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<a:MobileComplaintID>29292</MobileComplaintID> 
</mc> 
</Save> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>



<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Body> 
<Save xmlns="http://tempuri.org/"> 
 <UserID>229001</UserID> 
<mc> 
<MobileComplaintID>29292</MobileComplaintID> 
</mc> 
</Save> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>

好吧,我有错字:

29292

29292 我错过了“a:”

现在他填写了对象中的一些属性,但不是全部!

有没有人知道如何发生这种情况?

1 个答案:

答案 0 :(得分:1)

我发现了自己!当您处于纯.NET环境中时,属性的顺序无关紧要。但是当你从Xcode转到C#时,订单必须正确。我现在将Order Property添加到DataContract中的所有DataMember属性,并在xcode中遵循该顺序

[DataMember(Order=1)]

迈克尔