我用2个异步操作创建了一个WCF服务。 WCFTestClient返回错误:
WCF测试客户端不支持该操作,因为它使用类型SendCreditTransferRequest。
我不明白ProcessingFault
操作工作和其他(SendCreditTransferRequest
)为什么不。
我的.svc
代码:
namespace SimulatorServices
{
public class RealTimePortType : IRealTimePortType
{
public void SendCreditTransferRequest(SendCreditTransferRequest request)
{
throw new NotImplementedException();
}
public void ProcessingFault(ProcessingFault1 request)
{
throw new NotImplementedException();
}
}
}
我的.svc.cs
代码:
namespace SimulatorServices
{
[ServiceContract]
public interface IRealTimePortType
{
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://realtime247.eu/realtime247/SendCreditTransferRequest")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void SendCreditTransferRequest(SendCreditTransferRequest request);
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://realtime247.eu/realtime247/ProcessingFault")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void ProcessingFault(ProcessingFault1 request);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
[KnownType(typeof(TransactionHeader))]
[KnownType(typeof(Document))]
public partial class SendCreditTransferRequest
{
[System.ServiceModel.MessageHeaderAttribute(Namespace = "urn:eu:nets:realtime247:ri.2015.10.14")]
public TransactionHeader TransactionHeader;
[System.ServiceModel.MessageBodyMemberAttribute(Name = "SendCreditTransferRequest", Namespace = "urn:eu:nets:realtime247:ri.2015.10.14", Order = 0)]
public Document SendCreditTransferRequest1;
public SendCreditTransferRequest()
{
}
public SendCreditTransferRequest(TransactionHeader TransactionHeader, Document SendCreditTransferRequest1)
{
this.TransactionHeader = TransactionHeader;
this.SendCreditTransferRequest1 = SendCreditTransferRequest1;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
[KnownType(typeof(TransactionHeader))]
[KnownType(typeof(ProcessingFault))]
public partial class ProcessingFault1
{
[System.ServiceModel.MessageHeaderAttribute(Namespace = "urn:eu:nets:realtime247:ri.2015.10.14")]
public TransactionHeader TransactionHeader;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:eu:nets:realtime247:ri.2015.10.14", Order = 0)]
public ProcessingFault ProcessingFault;
public ProcessingFault1()
{
}
public ProcessingFault1(TransactionHeader TransactionHeader, ProcessingFault ProcessingFault)
{
this.TransactionHeader = TransactionHeader;
this.ProcessingFault = ProcessingFault;
}
}
}
对不起,但我没有复制我创建的所有课程...
我在没有课堂声明的情况下测试了我的操作,这些工作正常所以我逐步测试了SendCreditTransferRequest
的子类,我找到了问题的根源。我在AccountIdentification4Choice
中使用SendCreditTransferRequest
子类,它是pacs.008.001.02(它是ISO20022)xsd中的一个选择对象。
<xs:complexType name="AccountIdentification4Choice">
<xs:sequence>
<xs:choice>
<xs:element name="IBAN" type="IBAN2007Identifier"/>
<xs:element name="Othr" type="GenericAccountIdentification1"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
我这样定义:
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02")]
public partial class AccountIdentification4Choice
{
private object itemField;
[System.Xml.Serialization.XmlElementAttribute("IBAN", typeof(string), Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("Othr", typeof(GenericAccountIdentification1), Order = 0)]
public object Item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
}
但它失败了。所以新问题是,如何在WCF服务中声明一个选择对象?