如何解决在C#WCF DataMember集合上构建SOAP消息的问题
我正在创建一个简单的WCF服务以接受下面的SOAP消息。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jvm="http://siph.com/JVM">
<soapenv:Header/>
<soapenv:Body>
<jvm:MT_MedicationOrder>
<Patientid>?</Patientid>
<Case_number>?</Case_number>
<DateTime>?</DateTime>
<Order>
<MedicationOrder_id>?</MedicationOrder_id>
<Descr_of_order>?</Descr_of_order>
<!--Optional:-->
<Medication_req_type>?</Medication_req_type>
<!--Zero or more repetitions:-->
<Infusion_ingredient>
<Order_Id>?</Order_Id>
<DrugID>?</DrugID>
<DrugType>?</DrugType>
</Infusion_ingredient>
</Order>
</jvm:MT_MedicationOrder>
</soapenv:Body>
</soapenv:Envelope>
我在
服务合同
[ServiceContract(Namespace = "http://siph.com/JVM")]
public interface IMedicationOrder
{
[OperationContract]
MedicationOrderResponse ProcessOrder(MedicationOrderRequest req);
}
[MessageContract(WrapperName = "MT_MedicationOrder")]
public class MedicationOrderRequest
{
//[MessageHeader]
//public string Dummy;
#region Message Body
[MessageBodyMember(Namespace = "",Name = "Patientid",Order = 1)]
public string PatientId;
[MessageBodyMember(Namespace = "",Name = "Case_number",Order = 2)]
public string CaseNumber;
[MessageBodyMember(Namespace = "",Name = "DateTime",Order = 3)]
public string RequestDateTime;
[MessageBodyMember(Namespace = "",Name = "Order",Order = 4)]
public MedicationOrderTransaction OrderTransaction;
#endregion
}
MedicationOrderTransaction ServiceContract
[DataContract(Namespace = "")]
public class MedicationOrderTransaction
{
[DataMember(Name = "MedicationOrder_id",Order = 1,IsRequired = true)]
public string MedicationOrderID;
[DataMember(Name = "Descr_of_order",Order = 2)]
public string DescriptionOfOrder;
[DataMember(Name = "Medication_req_type",Order = 55)]
public string MedicationReqType;
[DataMember(Name = "Infusion_ingredient",Order = 56)]
public List<InfusionIngredientTransactionList> infusionIngredient;
}
DataContract InfusionIngredientTransactionList
[DataContract]
public class InfusionIngredientTransactionList
{
[DataMember(Name = "Order_Id",Order = 1)]
public string OrderID;
[DataMember(Name = "Drug_Id",Order = 2)]
public string DrugID;
[DataMember(Name = "DrugType",Order = 3)]
public string DrugType;
}
结果:请注意,在Infusion_Ingredient节点内创建了siph:InfusionIngredientTransactionList的集合,而不是应作为集合的Infusion_ingredient本身。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jvm="http://siph.com/JVM" xmlns:siph="http://schemas.datacontract.org/2004/07/SIPH.WebService.SAP.Model">
<soapenv:Header/>
<soapenv:Body>
<jvm:MT_MedicationOrder>
<Patientid>?</Patientid>
<Case_number>?</Case_number>
<DateTime>?</DateTime>
<Order>
<MedicationOrder_id>?</MedicationOrder_id>
<Descr_of_order>?</Descr_of_order>
<Medication_req_type>?</Medication_req_type>
<!--Optional:-->
<Infusion_ingredient>
<!--Zero or more repetitions:-->
<siph:InfusionIngredientTransactionList>
<!--Optional:-->
<siph:Order_Id>?</siph:Order_Id>
<!--Optional:-->
<siph:Drug_Id>?</siph:Drug_Id>
<!--Optional:-->
<siph:DrugType>?</siph:DrugType>
</siph:InfusionIngredientTransactionList>
</Infusion_ingredient>
</Order>
</jvm:MT_MedicationOrder>
</soapenv:Body>
</soapenv:Envelope>
请告诉我我做错了什么。谢谢。
解决方法
我还不能“评论”,所以尝试一个答案。因此,此建议可能无法实现,但会有所帮助:
if (!!objData.kenuze) {
formdata.append('keuze',objdata.keuze);
}
我也同意C#类应该位于List 属性之上,因为该类的对象已添加到List 集合中。如果您不在主题上或对您没有帮助,我深表歉意。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。