簡體   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