简体   繁体   中英

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

I have problem to make a client with axis2-1.6.2 Then I summarize the problem.

I'm trying to use the next wsdl to make a client: http://www.mobilefish.com/services/web_service/countries.php?wsdl

I'm using this line in windows:

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

I'm using xmlbeans because with adb I have problems

When I try to use this client with the next code:

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 );
}

I'm receiving the next error :

Exception in thread "main" org.apache.axis2.AxisFault: No method specified in request. at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at com.mobilefish.webservice.countries.CountriesWebserviceMobilefishComServiceStub.countryInfoByIana(CountriesWebserviceMobilefishComServiceStub.java:462) at Main.main(Main.java:33)

Please if someone can help with this problem would greatly appreciate it. Thanks in advance.

Looks a lot like the web service doesn't have the information it needs to properly dispatch the message. You're calling an RPC/encoded style web service which expects it's operation to be called by supplying a message payload wrapped with the name of the operation. Verify that this is actually happening and your raw SOAP messages contain the operation name.

Another possibility is that the service might require you populate the soap action header for it to be able to process your request. Populate this http header and see what happens

I'm here to answer my own question, exactly I don't know what happen with axis2 when I consume the webservice, after the error that I reported here I had a lot of new errors ,but I can solve this problem using axis1.4 to consume all the operations of the web service.

Just I create the Objects :

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

And then I use the next code:

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 ] );
    }

}

Maybe is not possible to consume the web service with axis2 I don't know but now I find out this solution which is valid to me.

Thanks anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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