我为肥皂故障定义了一个自定义模式,如下所示: ... ...
我在 VS 2008 中生成了代码:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.zurich.com/zsoa/corporate/common/2008/08/fault")]
[System.Xml.Serialization.XmlRootAttribute("zsoaFault", Namespace="http://schemas.zurich.com/zsoa/corporate/common/2008/08/fault", IsNullable=false)]
public partial class ZSOAFault : AbstractFault
{
...
我开发了一个自定义的 IErrorHandler (框架的一部分运送到所有项目),它会生成这个自定义的肥皂错误,如下所示:
Schemas.ZSOAFault.ZSOAFault zfault = new Schemas.ZSOAFault.ZSOAFault();
zfault.message = "hello";
zfault.operation = "operation";
zfault.serviceContext = "serviceContext";
zfault.serviceEndpoint = "serviceEndpoint";
zfault.timeStamp = DateTime.Now;
FaultException<Schemas.ZSOAFault.ZSOAFault> fe = new FaultException<Schemas.ZSOAFault.ZSOAFault>(zfault);
MessageFault msgFault = fe.CreateMessageFault();
重要的是,类 Schemas.ZSOAFault.ZSOAFault 是从模式生成的,而不是从也导入相同模式的应用程序 wsdl 生成的。
但是当我查看这个返回的肥皂错误时,我看到了一个不同的命名空间:
<detail>
<ZSOAFault xmlns="http://schemas.datacontract.org/2004/07/Schemas.ZSOAFault" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<message>hello</message>
<exception i:nil="true"/>
<operation>operation</operation>
<serviceContext>serviceContext</serviceContext>
<serviceEndpoint>serviceEndpoint</serviceEndpoint>
<timeStamp>2010-07-14T14:31:58.5437649+02:00</timeStamp>
</ZSOAFault>
</detail>
我希望在架构中看到自定义故障定义的命名空间,还是我错了?
谢谢奥利弗