2017-11-22 8 views
0

TomcatのajaxにWebサービスがあり、ksoap2を使用してAndroidクライアントでWebサービスを使用したいと考えています。これらはURLである私のWSパラメータが不足している場合は、Androidとksoap2を使用してWSDLを呼び出す方法は?

targetNamespace="http://localhost:8080/axis/AcademicService.jws" 

とで、私はこれらを持って

String NAMESPACE = "..."; 
String URL= ""; 
String SOAP_ACTION = "..."; 
String METHOD= "..."; 

:私は、チュートリアルを見ていると、すべての(またはほとんどのcrediblesの一つは、少なくとも)私は4つの文字列パラメータを埋める必要があることを言いますブラウザのアドレスバーに表示されます。 http://localhost:8080/axis/AcademicService.jws?wsdl

これら2つの違いは何ですか?私は、名前空間がtargetNamespaceフィールドであることは知っていますが、URLと同じですか、それとも別の場所ですか?

METHODのための次とSOAP_ACTIONは、私はそれは、それぞれの操作名とのsoapActionされるべきだと思う:私はのsoapActionとURLをしないのです場合でも

<wsdl:operation name="getClassByHour"> 
<wsdlsoap:operation soapAction=""/> 

私はまだWSを呼び出すことができますか?

答えて

0

これはあなた

public class KSOP { 

    public final String[] SOAP_ACTION =new String[]{ 
      "http://tempuri.org/Login", 
      "http://tempuri.org/NewPassword", 
      "http://tempuri.org/SerialNumber", 
      "http://tempuri.org/RegistrationWithPhonenumber", 
      "http://tempuri.org/Recovery", 



    }; 

    public final String[] OPERATION_NAME =new String[]{ 
      "Login", 
      "NewPassword", 
      "SerialNumber", 
      "RegistrationWithPhonenumber", 
      "Recovery", 


    }; 

    public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; 

    public final String SOAP_ADDRESS = "http://www.1111111.com/Webservice1.asmx"; 


    public String[] getNames(int i){ 
     String[] names=new String[10]; 
     switch (i) { 
      case 0: 
       names[0] = "username"; 
       names[1] = "pwd"; 
       return names; 
      case 1: 
       names[0] = "pwd"; 
       names[1] = "session"; 
       return names; 
      case 2: 
       names[0] = "serial"; 
       return names; 
      case 3: 
       names[0] = "username"; 
       names[1] = "pwd"; 
       names[2] = "phonenumber"; 
       names[3] = "name"; 
       names[4] = "lastname"; 
       names[5] = "serial"; 
       return names; 
      case 4: 
       names[0] = "username"; 
       names[1] = "phonenumber"; 
       return names;    
      case 6: 
       names[0] = "username"; 
       names[1] = "session"; 
       names[2] = "year"; 
       names[3] = "month"; 
       return names; 
      default: 
       return null; 
     } 
    } 
    public String doWork(String[] values,int action) 
    { 
     SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME[action]); 

     String[] s=getNames(action); 

      for (int i = 0; i < values.length; ++i) { 
       PropertyInfo pi = new PropertyInfo(); 
       pi.setName(s[i]); 
       pi.setValue(values[i]); 
       pi.setType(String.class); 
       request.addProperty(pi); 
      } 

     SoapSerializationEnvelope envelope; 
     envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 

     envelope.setOutputSoapObject(request); 

     HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS,10000); 
     Object response=null; 
     try 
     { 
      httpTransport.call(SOAP_ACTION[action], envelope); 
      response = envelope.getResponse(); 
     } 
     catch (Exception exception) 
     { 
      return "2"; 
     } 
     return response.toString(); 
    } 
} 
と共有するつもりは私の貴重なコードの一部であります
関連する問題