Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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();
	}
}
Posted

1 solution

Hi,

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

Client side:
Java
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:
VB
<WebMethod()> _
Public Sub setPicture(base64 As XmlNode, fileName As XmlNode)
End Sub



Hope it'll help you,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900