使用android中的kSoap resquest发送参数值,用于asmx服务 [英] Sending parameters values with kSoap resquest in android , for asmx service

查看:66
本文介绍了使用android中的kSoap resquest发送参数值,用于asmx服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以调用零参数的Web服务方法,但是当我尝试调用参数化的Web服务方法时,参数的值在服务时为空。



我认为代码很好,因为当我使用w3schools的温度转换服务时,它可以工作。但它不能与我的服务一起使用。任何人都可以告诉我我做错了。



代码:



I am able to call a web service method with zero parameters, but when i am trying to call a parameterised web method of service, value of paramerts is null at service.

I think code is fine, as when i use temperature conversion service of w3schools, it works. But it don't work with my service. Can any one tell me the mistake i have done.

Code:

package com.example.webservicesample;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
 
public class CallSoap {
	public final String SOAP_ACTION = "http://roomies.net.in/Add";

	public final String OPERATION_NAME = "Add";

	public final String WSDL_TARGET_NAMESPACE = "http://roomies.net.in";

	public final String SOAP_ADDRESS = "http://roomies.net.in/WebService1.asmx";

	public CallSoap() {
	}

	public String Call(int a, int b) {
		SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
				OPERATION_NAME);

		request.addProperty("a","pardeep");
		request.addProperty("b","kumar");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;

	
		envelope.setOutputSoapObject(request);

		HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
		Object response = null;
		try {
			httpTransport.call(SOAP_ACTION, envelope);
			response = envelope.getResponse();
		} catch (Exception exception) {
			response = exception.toString();
		}
		return response.toString();
	}
}

推荐答案





以下是我用来将图片上传到asmx网络服务的一些代码,



客户端:

Hi,

Here is a bit of code I'm using to upload pictures to asmx web service,

Client side:
SoapObject request = new SoapObject("http://tempuri.org/", "setPicture");

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

PropertyInfo prop = new PropertyInfo();
prop.setName("base64");
prop.setValue(base64);
prop.setType(String.class);
request.addProperty(prop);

prop = new PropertyInfo();
prop.setName("fileName");
prop.setValue(fileName);
prop.setType(String.class);
request.addProperty(prop);

HttpTransportSE androidHttpTransport = new HttpTransportSE("http://192.168.30.211:8080/WS/Service1.asmx", WebServiceHelper.WS_REQUEST_TIMEOUT);

try {
     androidHttpTransport.call("http://tempuri.org/setPicture", envelope);
     envelope.getResponse();
} catch (final Exception e) {
     error = true;
}





服务器端:



Server side:

<WebMethod()> _
Public Sub setPicture(base64 As XmlNode, fileName As XmlNode)
End Sub







希望它能为您提供帮助,




Hope it'll help you,


这篇关于使用android中的kSoap resquest发送参数值,用于asmx服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆