【问题标题】:generate ws client with wsdl and axis2使用 wsdl 和 axis2 生成 ws 客户端
【发布时间】:2015-02-01 13:17:09
【问题描述】:

我有这个 wsdl

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-hudson-48-. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-hudson-48-. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice.consulta.spcjava.spcbrasil.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://webservice.consulta.spcjava.spcbrasil.org/" name="consultaWebService">
<types>
<xsd:schema>
<xsd:import namespace="http://webservice.consulta.spcjava.spcbrasil.org/" schemaLocation="https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1" />
</xsd:schema>
</types>
<message name="consultar">
<part name="filtro" element="tns:filtro" />
</message>
<message name="consultarResponse">
<part name="resultado" element="tns:resultado" />
</message>
<message name="listarProdutos" />
<message name="listarProdutosResponse">
<part name="produtos" element="tns:produtos" />
</message>
<message name="detalharProduto">
<part name="codigo-produto" element="tns:codigo-produto" />
</message>
<message name="detalharProdutoResponse">
<part name="produto" element="tns:produto" />
</message>
<portType name="consultaWebService">
<operation name="consultar">
<input message="tns:consultar" />
<output message="tns:consultarResponse" />
</operation>
<operation name="listarProdutos">
<input message="tns:listarProdutos" />
<output message="tns:listarProdutosResponse" />
</operation>
<operation name="detalharProduto">
<input message="tns:detalharProduto" />
<output message="tns:detalharProdutoResponse" />
</operation>
</portType>
<binding name="consultaWebServicePortBinding" type="tns:consultaWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="consultar">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="listarProdutos">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="detalharProduto">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="consultaWebService">
<port name="consultaWebServicePort" binding="tns:consultaWebServicePortBinding">
<soap:address location="https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService" />
</port>
</service>
</definitions>

当我用axis2生成wsdl时出现错误

在为 WSDL 生成代码期间发生异常:org.apache.axis2.AxisFault: WSDLException (at /definitions/types/xsd:schema): faultCode=OTHER_ERROR: 尝试解析“https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1”引用的架构时发生错误,相对于 'file:/C:/Users/Tiago Roque/workspace/spe/WebContent/WEB-INF/ws/consultaWebService.xml.wsdl'.: java.io.IOException: Server returned HTTP response code: 401 for URL :https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1

我使用 eclipse 生成 有人可以帮我吗?

【问题讨论】:

    标签: eclipse wsdl jax-ws axis2


    【解决方案1】:

    wsdl 引用了一个受访问保护的外部 xml 模式(请参阅xsd:import)。这就是您收到 401 (UNAUTHORIZED) 错误 (https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1) 的原因。

    您可能可以请求 wsdl 的内联版本(其中所有架构定义都内联在一个完整的 wsdl 中)。

    【讨论】:

    • 当我使用netbeans并尝试不使用axis2时:new \ client to webservice \ Local File出现要输入的用户和密码并生成客户端但不是axis2格式。 eclipse中的axis2也应该显示用户和密码?
    • 根据当前的轴文档,这可能无法实现(至少我找不到任何关于它的信息)。但由于您正在处理 HTTP 基本身份验证,您可以在 URL 中传递凭据:https://user:secretpassword@example.com/path/to/wsdl
    • 看到很奇怪,在我的工作中我有 Eclipse 的 6 月版本,今天我设法生成,出现用户 wsdl 和密码并生成了 web 服务客户端。我认为问题出在我家中安装的 Luna 版本的 Eclipse 上。
    • 坦克命中注定你的帮助
    猜你喜欢
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-13
    • 2012-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多