具有复杂类型的 Axis WSDL 无法验证
我正在经历一些 wsdl 模式名称空间地狱。
我有一个来自 Axis Web 服务的 WSDL,并且我正在努力使用 WCF 生成存根服务以用于测试目的。
问题是,SVCUTIL 工具可以很好地生成代码,但是在托管时,不会公开任何方法。
我检查了 WSDL,发现有一行验证失败。我试图检查这是否是罪魁祸首,但名称空间太混乱了,我无法弄清楚它的情况。
所以,WSDL 大致是这样的。我省略了 WSDL 绑定、服务和端口,因为我只想专注于理解命名空间问题。
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://p1-services.customer.com/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://returnobject.foo.bar.com/xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://ws.receiver.foo.bar.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://p1-services.customer.com/">
<wsdl:documentation>WSP1IA01Service</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://returnobject.foo.bar.com/xsd">
<xs:complexType name="ReturnEnvelope">
<xs:sequence>
<!-- Simplified -->
<xs:element minOccurs="0" name="errorCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ns="http://ws.receiver.foo.bar.com" attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://ws.receiver.foo.bar.com">
<xs:element name="setMessage">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="xmlMessage" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="setMessageResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:ReturnEnvelope"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
验证失败的位是对 SetMessageResponse 元素中 ns0:ReturnEnvelope 的引用。它说找不到该类型。
我无法理解为什么,因为上面声明的类型的 targetNamespace 指向 NS0 前缀。
有什么想法吗?这些类型声明应该这么复杂吗?
另外,这个构造的目的是什么:
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
我读到它声明了前缀“ax22”以便在子元素中进一步使用。但它没有被使用,并且与 NS0 命名空间发生冲突。
感谢您的帮助
I'm experiencing some wsdl schema namespace hell.
I have a WSDL that came from an Axis web service and I'm tyring to generate a stub service with WCF for testing purposes.
Problem is, the SVCUTIL tool generates code fine but, when hosted, no methods are exposed.
I checked the WSDL and there is a line that fails validation. I'm trying to check if that is the culprit but the namespaces are such a mess that i cannot make heads or tails of it.
So, The WSDL is roughly this. I have ommited the WSDL Bindings, Services and Ports, as I just want to focus on understanding the namespaces problem.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://p1-services.customer.com/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://returnobject.foo.bar.com/xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://ws.receiver.foo.bar.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://p1-services.customer.com/">
<wsdl:documentation>WSP1IA01Service</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://returnobject.foo.bar.com/xsd">
<xs:complexType name="ReturnEnvelope">
<xs:sequence>
<!-- Simplified -->
<xs:element minOccurs="0" name="errorCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ns="http://ws.receiver.foo.bar.com" attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://ws.receiver.foo.bar.com">
<xs:element name="setMessage">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="xmlMessage" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="setMessageResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:ReturnEnvelope"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
The bit that fails validation is the reference to ns0:ReturnEnvelope in the SetMessageResponse element. It says that the type cannot be found.
I cannot understand why, as the type is declared above with targetNamespace pointing to the NS0 prefix.
Any ideas? Should those type declarations be so complicated?
Aditionally, what's the purpose of this construct:
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
I've read that that declares the prefix "ax22" for further use in child elements. But it isn't being used and it collides with the NS0 namespace.
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不熟悉您的工具集,但我可以看到一个可能导致问题的问题。首先,一些基线:
wsdl:types 中定义了两种模式。第一个用于命名空间
http://returnobject.foo.bar.com/xsd
,其中包含类型ReturnEnvelope
。第二个模式用于命名空间
http://ws.receiver.foo.bar.com
并定义一个setMessageResponse
类型为ReturnEnvelope
的元素http://returnobject.foo.bar.com/xsd
命名空间。ax22
未使用且不必要,但它的存在不会干扰表示相同命名空间的ns0
。第二个模式定义可以“看到”ns0,因为第二个模式定义嵌套在定义前缀的
wsdl:definitions
内。但是,第二个模式无法使用该命名空间(第一个模式)的模式内容;他们是没有血缘关系的兄弟姐妹。要允许使用另一个命名空间的类型,您需要将xs:import
元素添加到第二个架构中:根据工具,您可能还必须使用
schemaLocation< 告诉它该架构所在的位置/code>,但希望它能弄清楚,因为它们彼此相邻。
I'm not familiar with your toolset, but I can see one issue that could be causing the problem. First, some baseline:
There are two schemas defined in
wsdl:types
. The first one is for the namespacehttp://returnobject.foo.bar.com/xsd
which contains the typeReturnEnvelope
.The second schema is for the namespace
http://ws.receiver.foo.bar.com
and defines an elementsetMessageResponse
with typeReturnEnvelope
from thehttp://returnobject.foo.bar.com/xsd
namespace.ax22
is not used and unnecessary, but its presence doesn't interfere withns0
representing the same namespace.The second schema definition can "see" ns0 because the second schema definition is nested inside
wsdl:definitions
where the prefix is defined. However, the second schema can't use the contents of the schema for that namespace (the first schema); they are unconnected siblings. To allow use of another namespace's types, you need to add anxs:import
element to the second schema:Depending on the tools you may also have to tell it where that schema lives using
schemaLocation
, but hopefully it can figure it out since they're right next to each other.