使用wsdl和axis2生成ws客户端

时间:2015-02-01 13:17:10

标签: eclipse wsdl jax-ws axis2

我有这个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(在/ definitions / types / xsd:schema):faultCode = OTHER_ERROR:尝试解析在{{3}引用的模式时发生错误}',相对于'file:/ C:/ Users / Tiago Roque / workspace / spe / WebContent / WEB-INF / ws / consultaWebService.xml.wsdl':java.io.IOException:服务器返回HTTP响应代码:401对于网址:https://servicos.spc.org.br:443/spc/remoting/ws/consulta/consultaWebService?xsd=1

我使用eclipse进行生成 有人能帮助我吗?

1 个答案:

答案 0 :(得分:2)

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

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