本文介绍了我应该怎么称呼这种肥皂web服务从一个Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该怎么称呼这种肥皂web服务从一个Android
How should I call this Soap Webservice from an android
<AddCar xmlns="http://abcd.com/">
<clsAddCarRequest>
<clsCredentials>
<EmailAddress>string</EmailAddress>
<Password>string</Password>
<TokenID>string</TokenID>
</clsCredentials>
<clsCar>
<CarID>int</CarID>
<UserID>int</UserID>
<RegisteredOwner>string</RegisteredOwner>
<Make>string</Make>
<Model>string</Model>
<Color>string</Color>
<BodyType>string</BodyType>
<PlateType>string</PlateType>
<PlateNumber>string</PlateNumber>
<State>string</State>
<VINNumber>string</VINNumber>
<YearOfRegistration>int</YearOfRegistration>
<ExpiryDate>string</ExpiryDate>
<IsAutoFightOn>boolean</IsAutoFightOn>
<IsDeleted>boolean</IsDeleted>
<DateAddedTimeStamp>string</DateAddedTimeStamp>
<LastUpdatedTimeStamp>string</LastUpdatedTimeStamp>
</clsCar>
</clsAddCarRequest>
</AddCar>
类clsAddCarRequest为2个属性clsCredentials X,clsCar℃;
The class clsAddCarRequest as 2 properties clsCredentials x, clsCar c;
clsCredentials X;
clsCredentials x;
x.getXML返回以下
x.getXML returns the below
<clsCredentials>
<EmailAddress>string</EmailAddress>
<Password>string</Password>
<TokenID>string</TokenID>
</clsCredentials>
clsCar℃;
clsCar c;
c.getXML返回以下
c.getXML returns the below
<clsCar>
<CarID>int</CarID>
<UserID>int</UserID>
<RegisteredOwner>string</RegisteredOwner>
<Make>string</Make>
<Model>string</Model>
<Color>string</Color>
<BodyType>string</BodyType>
<PlateType>string</PlateType>
<PlateNumber>string</PlateNumber>
<State>string</State>
<VINNumber>string</VINNumber>
<YearOfRegistration>int</YearOfRegistration>
<ExpiryDate>string</ExpiryDate>
<IsAutoFightOn>boolean</IsAutoFightOn>
<IsDeleted>boolean</IsDeleted>
<DateAddedTimeStamp>string</DateAddedTimeStamp>
<LastUpdatedTimeStamp>string</LastUpdatedTimeStamp>
</clsCar>
clsAddCarRequest myReq;
clsAddCarRequest myReq;
myReq.getXML返回以下
myReq.getXML returns the below
<clsAddCarRequest>
<clsCredentials>
<EmailAddress>string</EmailAddress>
<Password>string</Password>
<TokenID>string</TokenID>
</clsCredentials>
<clsCar>
<CarID>int</CarID>
<UserID>int</UserID>
<RegisteredOwner>string</RegisteredOwner>
<Make>string</Make>
<Model>string</Model>
<Color>string</Color>
<BodyType>string</BodyType>
<PlateType>string</PlateType>
<PlateNumber>string</PlateNumber>
<State>string</State>
<VINNumber>string</VINNumber>
<YearOfRegistration>int</YearOfRegistration>
<ExpiryDate>string</ExpiryDate>
<IsAutoFightOn>boolean</IsAutoFightOn>
<IsDeleted>boolean</IsDeleted>
<DateAddedTimeStamp>string</DateAddedTimeStamp>
<LastUpdatedTimeStamp>string</LastUpdatedTimeStamp>
</clsCar>
</clsAddCarRequest>
我怎么叫SoapObject请求=新SoapObject
How do I call the SoapObject request = new SoapObject
在web服务回报
<AddCarResponse xmlns="http://abcd.com/">
<AddCarResult>string</AddCarResult>
</AddCarResponse>
推荐答案
这code为我工作。
String SOAP_ACTION = "http://rytryryry.com/AddCar";
String Email = "[email protected]";
String passWRD ="hai";
String token = "4535677756";
String server = "http://ytrytrytryty.org/Services.asmx";
String date=(String) android.text.format.DateFormat.format("MM/dd/yy h:mm:ss aa", new java.util.Date());
//date format "MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
try {
//System.out.println("in try blok");
URL u = new URL(server);
URLConnection uc = u.openConnection();
HttpURLConnection connection = (HttpURLConnection) uc;
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("SOAPAction", SOAP_ACTION);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "text/xml; charset=utf-8");
String xmldata = "<?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>"+
"<AddCar xmlns=\"http://abcd.com/\">"+
"<clsAddCarRequest>"+
"<clsCredentials>"+
"<EmailAddress>"+Email+"</EmailAddress>"+
"<Password>"+passWRD+"</Password>"+
"<TokenID>"+token+"</TokenID>"+
"</clsCredentials>"+
"<clsCar>"+
"<CarID>"+01+"</CarID>"+
"<UserID>"+34+"</UserID>"+
"<RegisteredOwner>"+"kishore"+"</RegisteredOwner>"+
"<State>"+"string"+"</State>"+
"<VINNumber>"+"string"+"</VINNumber>"+
"<YearOfRegistration>"+"2007"+"</YearOfRegistration>"+
"<ExpiryDate>"+"2/5/2016"+"</ExpiryDate>"+
"<IsAutoFightOn>"+true+"</IsAutoFightOn>"+
"<IsDeleted>"+false+"</IsDeleted>"+
"<DateAddedTimeStamp>"+date+"</DateAddedTimeStamp>"+
"<LastUpdatedTimeStamp>"+date+"</LastUpdatedTimeStamp>"+
"</clsCar>"+
"</clsAddCarRequest>"+
"</AddCar>"+
"</soap:Body>"+
"</soap:Envelope>";
System.out.println(xmldata);
OutputStream out = connection.getOutputStream();
Writer wout = new OutputStreamWriter(out);
wout.write(xmldata);
wout.flush();
wout.close();
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
//InputStream in = connection.getInputStream();
String result;
//int c;
while ((result=rd.readLine()) != null) {
System.out.println(result);
这篇关于我应该怎么称呼这种肥皂web服务从一个Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!