2015-01-31 5 views
-1

API 서비스가 노트 속성을 포함하고 있기 때문에 안드로이드에서 전화 서비스 ksoap에 문제가있어서 서비스를 요청하지 않습니다. 제발 도와주세요. android에서 Ksoap으로 Webservice를 호출하는 방법은 무엇입니까?

이 난 안드로이드의 API 서비스를 호출 코드 API 서비스

/api.asmx HTTP/1.1 
Host: xxxx 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://tempuri.org/RegisterEx" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <RegisterEx xmlns="http://tempuri.org/"> 
     <objCustReg> 
     <CustomerID>int</CustomerID> 
     <Firstname>string</Firstname> 
     <Lastname>string</Lastname> 
     <Email>string</Email> 
     <Passwd>string</Passwd> 
     <Phone>string</Phone> 
     <Address>string</Address> 
     <City>string</City> 
     <State>string</State> 
     <Zipcode>string</Zipcode> 
     <Country>string</Country> 
     <RegisterDate>string</RegisterDate> 
     <RegisteryBy>string</RegisteryBy> 
     <Credit /> 
     </objCustReg> 
     <Username>string</Username> 
     <Passwd>string</Passwd> 
    </RegisterEx> 
    </soap:Body> 
</soap:Envelope> 

입니다.

   String nameSpace = "http://tempuri.org/"; 
       String methodName = "RegisterEx"; 
       // EndPoint 
       String endPoint = "http://xxxxx.info/xxxx.asmx"; 
       // SOAP Action 
       String soapAction = "http://tempuri.org/RegisterEx"; 
       SoapObject rpc = new SoapObject(nameSpace, methodName); 
       SoapObject rpc2 = new SoapObject(nameSpace, methodName); 
       rpc2.addProperty("CustomerID", "1"); 
       rpc2.addProperty("Firstname", "boy"); 
       rpc2.addProperty("Lastname", "boy"); 
       rpc2.addProperty("Email", "[email protected]"); 
       rpc2.addProperty("Passwd", "123456"); 
       rpc2.addProperty("Phone", "123465789"); 
       rpc2.addProperty("Address", "address"); 
       rpc2.addProperty("City", "city"); 
       rpc2.addProperty("State", "2222"); 
       rpc2.addProperty("Zipcode", "2222"); 
       rpc2.addProperty("RegisterDate", ""); 
       rpc2.addProperty("RegisteryBy", ""); 
       rpc2.addProperty("Country", "USA"); 
       rpc.addProperty("objCustReg", rpc2); 
       rpc.addProperty("sWSUsername", "user"); 
       rpc.addProperty("sWSPasswd", "pass"); 

       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
         SoapEnvelope.VER10); 

       envelope.bodyOut = rpc; 
       envelope.dotNet = true; 
       envelope.setOutputSoapObject(rpc); 

       HttpTransportSE transport = new HttpTransportSE(endPoint); 
       try { 
        transport.call(soapAction, envelope); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
       SoapObject object = (SoapObject) envelope.bodyIn; 
       result = object.getProperty(0).toString(); 

내 코드 호출 서비스가 null을 반환합니다. 제발 도와주세요. 감사합니다!

답변

0

는 현재 objCustReg 유형 RegisterEx이다 렸기 때문에,

envelope.implicitTypes=true; 

를 추가하려고합니다. 그리고

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); 

귀하의 봉투에 XSI 및 XSD의 렸기 때문에

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

에 변경은 인쇄 예외 스택 추적을 나던 것을

2001 년 당신에게 확신입니다?