【发布时间】:2011-04-22 17:00:30
【问题描述】:
我正在经历一些 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 命名空间发生冲突。
感谢您的帮助
【问题讨论】: