【发布时间】:2019-04-25 06:53:02
【问题描述】:
我有一个用 Java 中的 Spring Boot 开发的 SOAP 1.1 服务,它可以毫无问题地响应我的任何请求并提供有效的 SOAP 响应。
现在的问题是,只要我将此服务作为服务引用添加到任何 .NET/C# 项目,就会创建引用并且我可以发送请求,但无法映射响应(肯定是从我的 SOAP 服务发送的)返回,我的 .NET 应用程序中的对象始终为空。
我已经发现问题可能出在哪里,但我不知道如何(甚至可能像这样)更改我的 xsd/wsdl 以正确生成所有源。
首先是我的 Java Spring Boot 项目中的 .xsd,用于生成 WSDL 和服务参考:
以下是 C# 项目中 Visual Studio 生成的服务参考的代码:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute([NAMESPACE]/processing", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]/base", IsNullable=true)]
public processingResponse processing([System.Xml.Serialization.XmlElementAttribute(Namespace="http://[NAMESPACE]/base", IsNullable=true)] processingRequest processingRequest) {
object[] results = this.Invoke("processing", new object[] {
processingRequest});
return ((processingResponse)(results[0]));
}
我发现如果我更改以下行
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]", IsNullable=true)]
并添加“Form=System.Xml.Schema.XmlSchemaForm.Unqualified”:
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]", IsNullable=true, Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
响应被正确映射到我的对象,目前它似乎像这样工作,没有任何问题。
问题是我想更改我的 .xsd 以从一开始就正确生成这些源 - 我已经尝试将 Form=Unqualified 添加到“processingResponse”complexType 内的“AppDataDataResult”元素,但它不起作用。
将此属性直接添加到 processingResponse 元素也不起作用,因为这是不可能的,因为
我还没有找到任何具体的解决方案,因为它似乎与 Spring Boot Framework Java 和 wsdl 的生成非常具体。
我希望有人可以帮助我解决这个问题,因为它似乎不是一个大问题(它“唯一”是一个需要在生成源代码期间添加的属性),但我似乎无法找到解决方案.提前感谢您的帮助!
【问题讨论】: