繁体   English   中英

错误:org.apache.axis2.AxisFault:请求中未指定方法

[英]Error: org.apache.axis2.AxisFault: No method specified in request

我有一个问题要用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。位于Main.main(Main.java:33)的webservice.countries.CountriesWebserviceMobilefishComServiceStub.countryInfoByIana(CountriesWebserviceMobilefishComServiceStub.java:462)

如果有人可以帮助解决这个问题,请多加赞赏。 提前致谢。

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

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

我在这里回答我自己的问题,我使用网络服务时我完全不知道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服务,但是现在我找到了对我有效的解决方案。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM