java - 从 WCF 和 Biztalk 中的 WSDL 导入键/值复杂类型定义

标签 java wcf wsdl biztalk

几天来我一直在为这个问题苦苦挣扎,不知道如何解决它。基本上我有以下 WSDL 服务定义:

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://sample.org/schemas/2012" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://sample.org/schemas/2012" name="SampleServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://sample.org/schemas/2012" schemaLocation="http://localhost:8080/sampleServices_war_exploded/sample?xsd=1"/>
</xsd:schema>
</types>
<message name="ExecuteSample">
<part name="parameters" element="tns:ExecuteSample"/>
</message>
<message name="ExecuteSampleResponse">
<part name="parameters" element="tns:ExecuteSampleResponse"/>
</message>
<message name="SampleException">
<part name="fault" element="tns:SampleException"/>
</message>
<portType name="SampleService">
<operation name="ExecuteSample">
<input wsam:Action="http://sample.org/schemas/2012/SampleService/ExecuteSampleRequest" message="tns:ExecuteSample"/>
<output wsam:Action="http://sample.org/schemas/2012/SampleService/ExecuteSampleResponse" message="tns:ExecuteSampleResponse"/>
<fault message="tns:SampleException" name="SampleException" wsam:Action="http://sample.org/schemas/2012/SampleService/ExecuteSample/Fault/SampleException"/>
</operation>
</portType>
<binding name="SampleServiceImplPortBinding" type="tns:SampleService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="ExecuteSample">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="SampleException">
<soap:fault name="SampleException" use="literal"/>
</fault>
</operation>
</binding>
<service name="SampleServiceImplService">
<port name="SampleServiceImplPort" binding="tns:SampleServiceImplPortBinding">
<soap:address location="http://localhost:8080/sampleServices_war_exploded/sample"/>
</port>
</service>
</definitions>

附带以下 XSD 文件定义:

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. --><xs:schema xmlns:tns="http://sample.org/schemas/2012" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://sample.org/schemas/2012">
<xs:element name="ExecuteSample" type="tns:ExecuteSample"/>
<xs:element name="ExecuteSampleResponse" type="tns:ExecuteSampleResponse"/>
<xs:element name="SampleException" nillable="true" type="tns:faultInfo"/>
<xs:complexType name="ExecuteSample">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="values">
<xs:complexType>
<xs:sequence>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="key" minOccurs="0" type="xs:string"/>
<xs:element name="value" minOccurs="0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ExecuteSampleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="faultInfo">
<xs:sequence/>
</xs:complexType>
</xs:schema>

好的,文档看起来不错,我们定义了一个名为 ExecuteSample(请求类型)的复杂类型,它包含两个成员,名称和值,最后一个是另一个复杂类型,其中包含一个名为“entry”的条目,其中包含键和值。

这看起来像字典,实际上是字典。它甚至使用“建议的”方式公开字典,唯一的区别是包含在“入口”参数中。

好吧,你猜怎么着,WCF svcutil biztalk 都不能识别 WSDL。 SVCUtil 和 Visual Studio 失败并出现一个非常愚蠢的错误,告诉我类似这样的事情:

Warning 1   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Object reference not set to an instance of an object.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://sample.org/schemas/2012']/wsdl:portType[@name='SampleService']   C:\src\biztalk\ConsoleApplication6\ConsoleApplication6\Service References\ServiceReference1\Reference.svcmap    1   1   ConsoleApplication6

biztalk WSDL 导入向导失败,没有任何错误消息,只是告诉我出了点问题...

我已经尝试了所有方法并在网络上查看了所有可能的方法,但没有任何结果。我很绝望,不知道到底发生了什么,一切看起来都很好,但无法正常工作...

奇怪……有什么想法吗?

最佳答案

您需要将 targetNamespace 添加到 wsdl 的类型部分中的架构标记。

<types>
    <xsd:schema targetNamepace="http://blah.org">
    ...
    </xsd:schema>
</types>

关于java - 从 WCF 和 Biztalk 中的 WSDL 导入键/值复杂类型定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225327/

相关文章:

c# - 无法在 WCF 中序列化字节数组

java - 使用 maven : CXF + java2ws goal 从 java 生成 WSDL

php - NuSoap soapClient 调用出现 "Premature end of data in tag html"错误

java - IE 如何失去执行 Java 小程序的能力?

java - Jpanel 未出现在 Safari 中

java - 在 java 中调用 oracle PL/SQL 函数 - 无效的列类型错误

c# - 等待 WCF 服务的最佳方式?

java - Swing GUI 和翻译器问题

objective-c - 将属性分配给 sudzc 中的对象

java - 使用 Java WSDL、Enum 和 Boolean 属性的 C# 不会根据请求发送