2011-11-30 243 views
0

我嘗試連接wsdl。服務wsdl包含複雜類型。但是,當試圖請求時,我得到一些錯誤。我的複雜類型wsdl在這裏。我需要先登錄才能使用其他方法。我的wsdl網址:http://dgpysws.teias.gov.tr/dgpys/services/EVDServis?wsdl。Android中的複雜類型肥皂

<xs:element name="login"> 
    <xs:complexType> 
    <xs:sequence> 
    <xs:element minOccurs="0" name="loginMessage" nillable="true" type="dgp:LoginMessage"/> 
    </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
    <xs:complexType name="LoginMessage"> 
    <xs:sequence> 
    <xs:element minOccurs="0" name="Password" nillable="true" type="dgp:StringValue"/> 
    <xs:element minOccurs="0" name="UserName" nillable="true" type="dgp:StringValue"/> 
    </xs:sequence> 
    </xs:complexType 

我的代碼下面

public class BuNeActivity extends Activity { 
    private static final String SOAP_ACTION = "http://ws.dgpys.deloitte.com/login"; 
    private static final String METHOD_NAME = "login"; 
    private static final String NAMESPACE = "http://ws.dgpys.deloitte.com"; 
    private static final String URL = "http://dgpysws.teias.gov.tr/dgpys/services/EVDServis?wsdl"; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     PropertyInfo username = new PropertyInfo(); 
     username.name="UserName"; 
     username.type=String.class; 
     username.setValue("..."); 

     PropertyInfo password = new PropertyInfo(); 
     password.name="Password"; 
     password.type=String.class; 
     password.setValue("..."); 

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
     request.addProperty(password); 
     request.addProperty(username); 


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

     envelope.setOutputSoapObject(request); 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     androidHttpTransport.debug = true; 
     Log.d("aa","s"); 
     try { 

      androidHttpTransport.call(SOAP_ACTION, envelope); 
      // Get the SAOP Envelope back and the extract the body 
     // Object resultsRequestSOAP = (Object) (() envelope).bodyIn(); 
     //  String deneme = resultsRequestSOAP.toString(); 
      Log.d("MyAPP", "----------------- " + androidHttpTransport.requestDump +"\n\n" + androidHttpTransport.responseDump); 
     //  Toast.makeText(this, deneme, Toast.LENGTH_LONG).show(); 
    }catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 
} 

我REQ。並在這裏迴應愚蠢;

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /> 
<v:Body> 
<login xmlns="http://ws.dgpys.deloitte.com" id="o0" c:root="1"><Password i:type="d:string">....</Password><UserName i:type="d:string">...</UserName></login></v:Body></v:Envelope> 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>unknown</faultstring><detail /></soapenv:Fault></soapenv:Body></soapenv:Envelope> 

回答

0

嘗試這樣的:

private static final String URL = "http://dgpysws.teias.gov.tr/dgpys/services/EVDServis/"; 

Web服務返回一個LoginMessage對象?在這種情況下,你應該這樣做:

... 
LoginMessage response = (LoginMessage)envelope.getResponse(); 
...