SoapFault - faultcode:'S:Client'faultstring:'在Android中调用JAX-WS找不到调度方法

时间:2012-04-21 21:04:21

标签: android web-services soap jax-ws

我正在尝试使用KSoap2 API在Android的glassfish服务器中调用部署在我的localhost中的java webservice。我在logcat中遇到以下异常:

04-22 02:24:53.251:W / System.err(251):SoapFault - faultcode:'S:客户端'faultstring:'无法找到{http:// abc /} ResponseFromDB的调度方法'faultactor:'null'detail:null 请帮忙。 我使用以下代码:

public class TestLocalWebserviceActivity extends Activity {
    /** Called when the activity is first created. */
    private static final String SOAP_ACTION = "http://abc/ResponseFromDB";

    private static final String OPERATION_NAME = "ResponseFromDB";

    private static final String WSDL_TARGET_NAMESPACE = "http://abc/";

    private static final String SOAP_ADDRESS = "http://116.202.210.193:8086/CalculatorWS/ResponseFromDB?wsdl";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        class fetchprojectdetails extends AsyncTask<String, Void, String> {

            ProgressDialog dialog;
            String SOAPresponse;

            @Override
            protected void onPreExecute() {
                // progress.show();

                dialog = ProgressDialog.show(TestLocalWebserviceActivity.this, "",
                        "Retrieving Data....", true);
                // progressDialog.setCancelable(true);
                dialog.show();
                dialog.setCancelable(true);
            }

            @Override
            protected String doInBackground(String... params) {

                // setContentView(textView);
                SoapObject result;

                SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
                        OPERATION_NAME);

                PropertyInfo propInfo=new PropertyInfo();
                  propInfo.name="name";
                  propInfo.type=PropertyInfo.STRING_CLASS;

                  request.addProperty("name", "John Smith");
                //request.addProperty("name", "ggg");

                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                        SoapEnvelope.VER11);
                //envelope.dotNet = true;
                //envelope.encodingStyle = SoapSerializationEnvelope.XSD;
                envelope.setOutputSoapObject(request);

                HttpTransportSE httpTransport = new HttpTransportSE(
                        SOAP_ADDRESS);

                try {
                    httpTransport.call(SOAP_ACTION, envelope);
                } catch (IOException e1) {
                    Log.d("io", ""+e1.getMessage());
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (XmlPullParserException e1) {
                    // TODO Auto-generated catch block
                    Log.d("xmlpullparser", ""+e1.getMessage());
                    e1.printStackTrace();
                }

                try {
                    SoapPrimitive  resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
                } catch (SoapFault e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Log.d("ee", ""+e.getMessage());
                }
                //httpTransport.debug = true;
                try

                {

                    //List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
                //  headerList.add(new HeaderProperty("Authorization", "Basic "+ org.kobjects.base64.Base64.encode(raw)));
                //  httpTransport.call(SOAP_ACTION, envelope, headerList);

                    //String gr = httpTransport.requestDump;
                    // Object response = envelope.getResponse();
                    //SOAPresponse = httpTransport.responseDump;

                    String resultsString = (String) envelope.getResponse();
                    String gg = resultsString;

                    // i = obj.execute(LearningScore.this);
                    // i.putExtra("LearningCredit", LearningCredit);

                    // startActivity(i);

                }

                catch (Exception exception)

                {
                    System.out.print(exception.getLocalizedMessage());
Log.d("eeeeee",""+exception.getLocalizedMessage()+exception.getMessage());
                    // Toast.makeText(LearningScore.this,"Successfully Authenticated",
                    // Toast.LENGTH_LONG).show();

                }
                return SOAPresponse;
            }

            @Override
            protected void onPostExecute(String result) {
                String gg = result;
                Log.d("message:  ", result+"");
                //Intent i = new Intent(ViewPHSActivity.this, ViewProjects.class);

                //projectxml = result;
                // .putExtra("response", result);
                //startActivity(i);

                dialog.dismiss();
                finish();
            }

        }
        new fetchprojectdetails().execute();
    }
}

WSDL:

  <?xml version="1.0" encoding="UTF-8" ?> 
- <!--  Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. 
  --> 
- <!--  Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. 
  --> 
- <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://abc/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://abc/" name="ResponseFromDB">
- <types>
- <xsd:schema>
  <xsd:import namespace="http://responseFromDb/" schemaLocation="http://localhost:8086/CalculatorWS/ResponseFromDB?xsd=1" /> 
  </xsd:schema>
- <xsd:schema>
  <xsd:import namespace="http://abc/" schemaLocation="http://localhost:8086/CalculatorWS/ResponseFromDB?xsd=2" /> 
  </xsd:schema>
  </types>
- <message name="hello">
  <part name="parameters" element="tns:hello" /> 
  </message>
- <message name="helloResponse">
  <part name="parameters" element="tns:helloResponse" /> 
  </message>
- <portType name="ResponseFromDB">
- <operation name="hello">
  <input wsam:Action="http://abc/ResponseFromDB/helloRequest" message="tns:hello" /> 
  <output wsam:Action="http://abc/ResponseFromDB/helloResponse" message="tns:helloResponse" /> 
  </operation>
  </portType>
- <binding name="ResponseFromDBPortBinding" type="tns:ResponseFromDB">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
- <operation name="hello">
  <soap:operation soapAction="" /> 
- <input>
  <soap:body use="literal" /> 
  </input>
- <output>
  <soap:body use="literal" /> 
  </output>
  </operation>
  </binding>
- <service name="ResponseFromDB">
- <port name="ResponseFromDBPort" binding="tns:ResponseFromDBPortBinding">
  <soap:address location="http://localhost:8086/CalculatorWS/ResponseFromDB" /> 
  </port>
  </service>
  </definitions>

0 个答案:

没有答案