Android中的复合型肥皂

时间:2011-11-30 09:11:20

标签: android ksoap2 complextype

我尝试连接wsdl。服务wsdl包含复杂类型。但是当试图请求时,我得到了一些错误。我的复杂类型wsdl在这里。我需要先登录才能使用其他方法。我的wldl网址:http://dgpysws.teias.gov.tr/dgpys/services/EVDServis?wsdl。

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

我的要求。并且在这里回应愚蠢;

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

1 个答案:

答案 0 :(得分:0)

试试这个:

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

您的网络服务是否正在返回LoginMessage对象?在这种情况下,你应该这样做:

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