您的位置:首页 > 编程语言 > Java开发

让Dotnet识别Java发送来的自定义SoapHeader

2009-02-23 16:57 197 查看
在异架构间通讯时,我们一般会采用WS。我遇到的情况是WSDL已经由AXIS生成,我需要用Dotnet实现服务器。

简单实现后,发现里面的 NotifySOAPHeader 总是取不值,添加 SoapUnknownHeader[] 后,里面有值。可见是不能识别AXIS发送来的SoapHeader。

仔细对比Dotnet生成的WSDL,和原来的定义的WSDL相关内容:

修正后的类实现
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1")]
[System.Xml.Serialization.XmlRootAttribute("NotifySOAPHeader",Namespace = "http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1", IsNullable = false)]
public class NotifySOAPHeader : System.Web.Services.Protocols.SoapHeader
{

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string spRevId;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string spRevpassword;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string spId;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string SAN;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string transactionId;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string linkId;
}
这样就可以了,不用再写代码从SoapUnknownHeader中取数据了。也没有必须为Java和Dotnet分别写一份代码。

是不是以后用Dotnet发布时,都用上这个声明呢?我经验不多,大家讨论一下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: