下面是我写的代码,用于validation用户login凭据。 使用.net编写的Web服务 private static final String SOAP_ACTION = "http://tempuri.org/getCredentials"; private static final String OPERATION_NAME = "getCredentials"; private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; private static final String SOAP_ADDRESS = "http://myStaticIP:portNo/WebSiteName/CommunicationInterface.asmx"; SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); request.addProperty("username",Username); request.addProperty("password", Password); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httptransport = new HttpTransportSE(SOAP_ADDRESS); try { […]
我需要将肥皂标题信息设置为Web方法身份validation的一部分。 我使用ksoap2 API调用.NET Web服务。 这是带请求的肥皂头。 <soap:Header> <DTHeader xmlns="http://myServer.com/webservices/"> <Username> string </Username> <Password> string </Password> </DTHeader> </soap:Header> <soap:Body> <MyTestMethod xmlns="http://myServer.com/webservices/"> <ID> string </ID> <TransID> guid </TransID> </MyTestMethod> </soap:Body> 你可以请提供android代码来设置肥皂头“DTHeader”,并设置“用户名”和“密码”。
调用Web服务时遇到问题。 我在服务器上有一个.NET Web服务,我在Android中使用KSOAP2(ksoap2-j2se-full-2.1.2)。 运行程序时,我得到了一个像“org.ksoap2.serialization.SoapPrimitive”运行时exception。 我该怎么办? 这是我的代码。 package projects.ksoap2sample; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.*; import android.os.*; import android.widget.TextView; public class ksoap2sample extends Activity { /** Called when the activity is first created. */ private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld"; private static final String METHOD_NAME = "HelloWorld"; private static final String […]