【问题标题】:Problem creating a web service from a WSDL从 WSDL 创建 Web 服务时出现问题
【发布时间】:2009-12-19 04:56:38
【问题描述】:

我遇到的问题是,当我尝试使用此 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。

[ERROR] Invalid wsdl:operation "RequestQuote": it a rpc-literal operation, me sage 部分必须引用模式类型声明 文件第 16 行:/D:/projects/DICACORD/QuoteRq2.wsdl

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

更新 2

请求的架构->。 Schema at pastie

加法

是否有人发现 xsd 导入和/或它们的使用方式有什么问题?

【问题讨论】:

  • 你在使用什么框架。Spring 让这一切变得非常简单。
  • 另外,你的 XSD 在哪里? (模式)
  • 每个模式超过 250 行。它能让我发布那么大的吗?
  • 嗯...正在使用 Spring 一个选项?是这样,我可以向您指出一个问题的方向,该问题将向您展示整个设置。我还可以为您提供一个教程……spring 很棒,因为它会为您即时生成 WSDL。
  • @Zoidberg 来吧,Spring 不会在这里解决任何问题。这不是 WS 堆栈问题……而且有些人确实想使用 WSDL-first 方法(不过,JAX-WS 也可以生成 WSDL)。

标签: java web-services wsdl netbeans6.8


【解决方案1】:

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

wsimport yourservice.wsdl

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

您提交的 WSDL 不完整,因为它引用了外部架构文件 (XSD),因此我无法验证它。

【讨论】:

    【解决方案2】:

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

    我不知道,但是在做了更多研究之后,当您想导入另一个 wsdl 但如果您想从 a 导入架构以使用其中定义的类型时,似乎应该使用 wsdl:import 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 服务之后才这样做。

    祝大家节日快乐。

    【讨论】:

      【解决方案3】:

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

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

      &lt;wsdl:import namespace="http://discoveryinsurance.com/DicQuoteSvc/schemas/" location="DicAcordQuoteRq.xsd"/&gt;

      【讨论】:

        猜你喜欢
        • 2011-07-18
        • 1970-01-01
        • 2020-09-02
        • 2010-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-11-11
        • 2017-06-08
        相关资源
        最近更新 更多