私は名前空間と契約が私によって定義されないように、特定のクライアントに対してWCFサービスを実装する必要があります。問題は、複合型をMessageBodyMember
として使用すると、サーバー側では、指定されたメンバーがサーバー側でnullに設定されることです。ここで複雑なタイプと名前空間を持つWCF MessageBodyMember
はサンプルリクエストです:あなたが見ることができるように
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:CustomeHeader xmlns:ns1="HEADER_NAMESPACE">
<version>1.0</version>
</ns1:CustomeHeader>
</soapenv:Header>
<soapenv:Body>
<ns2:in4 xmlns:ns2="NAMESPACE_1">
<ns39:userID xmlns:ns39="NAMESPACE_2">
<ns40:ID xmlns:ns40="NAMESPACE_3">someFakeID_123</ns40:ID>
<ns41:type xmlns:ns41="NAMESPACE_3">0</ns41:type>
</ns39:userID>
</ns2:in4>
</soapenv:Body>
</soapenv:Envelope>
、userID
は、そのメンバーは、名前空間を定義している複合型です。私が話しているのはMessageBodyMemberです。ここで
は、サービスおよび実装の私のインタフェース定義である:
[XmlSerializerFormat]
public interface IIntegrationService
{
[OperationContract]
[XmlSerializerFormat]
SyncOrderRelationshipRsp syncOrderRelationship(SyncOrderRelationshipReq syncOrderRelationshipReq);
}
[ServiceContract]
public class IntegrationService : IIntegrationService
{
public SyncOrderRelationshipRsp syncOrderRelationship(SyncOrderRelationshipReq syncOrderRelationshipReq)
{
//some code here ...
}
}
そしてここではSyncOrderRelationshipReq
とUserID
の定義です:
[MessageContract(IsWrapped = true, WrapperName = "in4", WrapperNamespace = "HEADER_NAMESPACE")]
public class SyncOrderRelationshipReq
{
[MessageHeader(Namespace = "HEADER_NAMESPACE")]
public IBSoapHeader IBSoapHeader { get; set; }
[MessageBodyMember(Namespace = "NAMESPACE_2")]
public UserID userID { get; set; }
}
[MessageContract(WrapperNamespace = "NAMESPACE_2", IsWrapped = true)]
public class UserID
{
[MessageBodyMember(Namespace = "NAMESPACE_3")]
public string ID { get; set; }
[MessageBodyMember(Namespace = "NAMESPACE_3", Name = "type")]
public int Type { get; set; }
}
長い話を短くするために、私はインナーが必要MessageBodyMemberのメンバーは、これらのメンバーを読むことができるように、独自の名前空間が設定されています。