1

我用axis2-1.6.2做客户端有问题然后我总结一下问题。

我正在尝试使用下一个 wsdl 来制作客户端:http ://www.mobilefish.com/services/web_service/countries.php?wsdl

我在 Windows 中使用这一行:

WSDL2Java.bat -uri http://www.mobilefish.com/services/web_service/countries.php?wsdl -d xmlbeans -s

我正在使用xmlbeans,因为使用adb我有问题

当我尝试将此客户端与下一个代码一起使用时:

public static void main(String[] args) throws RemoteException {

    CountriesWebserviceMobilefishComServiceStub countriWebService = 
    new CountriesWebserviceMobilefishComServiceStub("http://www.mobilefish.com/services/web_service/countries.php?wsdl");

    CountryInfoByIanaDocument cidocument = CountryInfoByIanaDocument.Factory.newInstance();
    CountryInfoByIana ci = CountryInfoByIana.Factory.newInstance();

    ci.setIanacode("us");
    cidocument.setCountryInfoByIana( ci );
    countriWebService.countryInfoByIana(  cidocument );
}

我收到下一个错误:

线程“主”org.apache.axis2.AxisFault 中的异常:请求中未指定方法。 在 org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) 在 org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) 在 org.apache.axis2.description.OutInAxisOperationClient.send (OutInAxisOperation.java:421) 在 org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) 在 org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) 在 com.mobilefish。 Webservice.countries.CountriesWebserviceMobilefishComServiceStub.countryInfoByIana(CountriesWebserviceMobilefishComServiceStub.java:462) 在 Main.main(Main.java:33)

请如果有人可以帮助解决这个问题,将不胜感激。提前致谢。

4

2 回答 2

0

看起来很像 Web 服务没有正确发送消息所需的信息。您正在调用一个 RPC/编码样式的 Web 服务,该服务期望通过提供一个包含操作名称的消息有效负载来调用它的操作。验证这确实发生了,并且您的原始 SOAP 消息包含操作名称。

另一种可能性是该服务可能需要您填充soap action标头以便它能够处理您的请求。填充这个 http 标头,看看会发生什么

于 2012-12-10T14:13:12.747 回答
0

我来这里是为了回答我自己的问题,确切地说我不知道​​使用 web 服务时axis2会发生什么,在我在这里报告的错误之后我有很多新错误,但我可以使用axis1解决这个问题。 4 消费web服务的所有操作。

只是我创建了对象:

java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java http://www.mobilefish.com/services/web_service/countries.php?wsdl

然后我使用下一个代码:

public static void main(String[] args) throws MalformedURLException, RemoteException, ServiceException {


    String  endpoint = "http://www.mobilefish.com/services/web_service/countries.php?wsdl";

    Service  service = new Service();
    Call     call    = (Call) service.createCall();

    call.setTargetEndpointAddress( new java.net.URL(endpoint) );
    call.setOperationName( "countryInfoByIana" );
    call.addParameter( "ianacode", XMLType.XSD_STRING, ParameterMode.IN );
    call.setReturnType(XMLType.SOAP_ARRAY);

    Object _resp = call.invoke( new Object [] { "us" });

    Object[] objetoArray = (Object[]) _resp;

    for(int i = 0; i< objetoArray.length; i++){
        System.out.println( objetoArray[ i ] );
    }

}

也许不可能使用我不知道的axis2来使用Web服务,但现在我发现了这个对我有效的解决方案。

不管怎么说,还是要谢谢你。

于 2012-12-12T16:54:53.920 回答