我最近一直在开发符合 ACORD P&C 的 Web 服务,并且遇到了一些来自 wsimport 的错误,说它无法解析其中一个 xsd 文件。错误信息是:
[ERROR] Unable to parse "D:\projects\DICACORD\DicAcordQuoteRq.xsd" : Illegal character in opaque part at index 2: D:\projects\DICACORD\DicAcordQuoteRq.xsd
我创建的架构基于 ACORD P&C 架构(超过 23k 行),并且我只包含了公司需要使用的必需元素。我使用 XMLSpy 创建了架构,根据其验证,架构是有效的,但是当我尝试在 netbeans 6.8 中创建 Web 服务时,我收到了上面的错误消息。
模式在我的开发机器上,根据我在 netbeans 论坛上可以找到的内容,netbeans 将 wsdl 复制到项目内部的目录中,这样当您将其从开发转移到生产时,一切仍然可以正常工作。
wsdl如下
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2010 -->
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="discoveryinsurance.com/schemas" xmlns:ns="discoveryinsurance.com/schemas/acordRq" xmlns:ns1="discoveryinsurance.com/schemas/acordRs" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="discoveryinsurance.com/schemas">
<wsdl:import namespace="discoveryinsurance.com/schemas/acordRq" location="D:\projects\DICACORD\DicAcordQuoteRq.xsd"/>
<wsdl:import namespace="discoveryinsurance.com/schemas/acordRs" location="D:\projects\DICACORD\DicAcordQuoteRs.xsd"/>
<wsdl:types>
<xs:schema targetNamespace="discoveryinsurance.com/schemas" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="NewMessageRequest">
<wsdl:part name="parameter" element="ns:ACORD"/>
</wsdl:message>
<wsdl:message name="NewMessageResponse">
<wsdl:part name="parameter" element="ns1:ACORD"/>
</wsdl:message>
<wsdl:portType name="QuotePort">
<wsdl:operation name="QuoteRequest">
<wsdl:input name="quoteInput" message="tns:NewMessageRequest"/>
<wsdl:output name="quoteOutput" message="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AgencyQuoteSOAP" type="tns:QuotePort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="QuoteRequest">
<soap:operation soapAction="urn:QuoteRequest" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AgencyQuote">
<wsdl:port name="QuotePort" binding="tns:AgencyQuoteSOAP">
<soap:address location="http://localhost:8084/DicQuoteSvc/AgencyQuote"/>
</wsdl:port>
</wsdl:service>
我觉得这与命名空间有关,但我不确定。这也是我第一次尝试以这种方式创建 Web 服务,因为我认为我会为自己节省一些开发时间。
我试过用谷歌搜索错误消息,我读到的所有内容都指向不正确的 URI。我在想 XMLSpy 的验证会捕捉到这样的错误,但如果这是问题所在,那么它就不会捕捉到它。
任何帮助将不胜感激,我很乐意提供任何其他需要的信息。