繁体   English   中英

从WSDL创建Web服务时出现问题

[英]Problem creating a web service from a WSDL

我遇到的问题是,当我尝试使用这个wsdl在netbeans中创建一个Web服务时,netbeans说没有定义服务。 我是整个wsdl的新手,但据我所知,有一个定义。

wsdl是:

 <?xml version="1.0" encoding="UTF-8"?>
 <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="http://discoveryinsurance.com/DicQuoteSvc/AgencyQuote.wsdl" xmlns:ns="http://discoveryinsurance.com/DicQuoteSvc/schemas/DicAcordQuoteRq.xsd" xmlns:na="http://discoveryinsurance.com/DicQuoteSvc/schemas/DicAcordQuoteRs.xsd" targetNamespace="http://discoveryinsurance.com/DicQuoteSvc/AgencyQuote.wsdl">
<wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/" location="DicAcordQuoteRq.xsd"/>
<wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/" location="DicAcordQuoteRs.xsd"/>
<wsdl:types>
    <xs:schema targetNamespace="http://discoveryinsurance.com/DicQuoteSvc/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="na:ACORD"/>
</wsdl:message>
<wsdl:portType name="QuotePortType">
    <wsdl:operation name="RequestQuote">
        <wsdl:input message="tns:NewMessageRequest"/>
        <wsdl:output message="tns:NewMessageResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="QuoteBinding" type="tns:QuotePortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="RequestQuote">
        <soap:operation soapAction="http://discoveryinsurance.com/DicQuoteSvc/AgencyQuote" style="rpc"/>
        <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="QuotePortType" binding="tns:QuoteBinding">
        <soap:address  location="http://discoveryinsurance.com/DicQuoteSvc/"/>
    </wsdl:port>
</wsdl:service>

XMLSpy说wsdl是有效的,但是当我尝试从它创建Web服务时它失败了。 任何帮助都会受到赞赏,甚至是建设性的批评。

编辑

我从命令行使用wsimport。

[错误]无效的wsdl:操作“RequestQuote”:它是一个rpc-literal操作,mes sage部分必须引用文件的模式类型声明第16行:/ D:/projects/DICACORD/QuoteRq2.wsdl

这是否意味着即使导入了两个xsd,我仍然需要在wsdl中定义类型?

更新2

请求的架构 - >。 在牧场的架构

加成

有没有人看到xsd导入有什么问题和/或它们是如何被使用的?

验证wsdl有效的最简单方法是从命令行运行:

wsimport yourservice.wsdl

看看它是否给你任何错误。 wsimport附带JDK 1.6

您提交的WSDL不完整,因为它引用了外部模式文件(XSD),因此我无法对其进行验证。

要回答我自己的问题,无法从wsdl创建Web服务的原因是由于使用了wsdl:import而不是xs:import

我不知道但是在做了一些研究之后,当你想要导入另一个wsdl时,似乎应该使用wsdl:import但是如果你想从a导入一个模式来使用你需要的wsdl中定义的类型使用xsd:import因为如果不是wsimport将找不到架构中定义的类型。

我变了

xmlns:ns="http://discoveryinsurance.com/DicQuoteSvc/schemas/DicAcordQuoteRq.xsd"
xmlns:na="http://discoveryinsurance.com/DicQuoteSvc/schemas/DicAcordQuoteRs.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:rq="http://discoveryinsurance.com/DicQuoteSvc/schemas/request/" 
xmlns:rs="http://discoveryinsurance.com/DicQuoteSvc/schemas/response/"

并改变了进口

<wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/"  location="DicAcordQuoteRq.xsd"/>
<wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/" location="DicAcordQuoteRs.xsd"/>

<xs:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/request/" schemaLocation="DicAcordQuoteRq.xsd"/>
<xs:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/response/" schemaLocation="DicAcordQuoteRs.xsd"/>

进行这些更改可以使Web服务成功构建,并且基于两个模式创建类。 希望当我星期一开始测试Web服务时,它将按照我的意愿工作。 感谢大家提供的输入,因为它让我了解了为什么从wsdl创建Web服务失败的其他原因。

我确实更改了它们所在的命名空间,但这是出于不同的原因,我在我的机器上本地创建和部署Web服务之后就这样做了。

大家节日快乐。

ACORD位于命名空间http://discoveryinsurance.com/DicQuoteSvc/schemas/DicAcordQuoteRq.xsd

在我看来,你导入的ACORD是无效的,因为它以不同方式识别ACORD的命名空间:

<wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/" location="DicAcordQuoteRq.xsd"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM