eclipse - 使用wsdl和axis2生成ws客户端

标签 eclipse wsdl jax-ws apache-axis

我有这个 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 时出现错误

Exception occurred during code generation for WSDL : org.apache.axis2.AxisFault: WSDLException (at /definitions/types/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1', relative to '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来生成 有人可以帮助我吗?

最佳答案

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

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

关于eclipse - 使用wsdl和axis2生成ws客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28263103/

相关文章:

java - 使用 maven selenium 插件启动浏览器 session 时无法删除文件

python - 使用来自 Python 的 WSDL 服务,它是我的客户端代码还是服务器?

java - 如何为 JAX-WS Web 服务客户端设置超时?

java - JAXB异常 : class not known to the context in CXF JAX-WS client with anyType parameter call

java - maven 项目警告 'DTD or XML schema' 上的 eclipse

java - 在每个 Eclipse 调试/运行时自动清除 LogCat?

java - 通过 Maven 导入的类出现 NoClassDef 错误

java : How to see web service description which is easy to understand not WSDL?

java - 使用 CXF 生成的客户端时意外的包装器元素

class - JAX-WS - Web 服务生成的类在哪里?