android 代码:
String WSDL_URI = "http://192.168.122.52:8080/DailyRpt/webservice?WSDL";
String namespace = "http://webservice/";
final String methodName = "soa";//要调用的方法名称
//可能是namspace+method拼接
final String soapAction = "http://webservice/soa";
SoapObject request = new SoapObject(namespace, methodName);
request.addProperty("name", "ab砂石c"); //创建SoapSerializationEnvelope 对象,同时指定soap版本号(之前在wsdl中看到的)
final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11); envelope.bodyOut = request;//由于是发送请求,所以是设置bodyOut
(new MarshalBase64()).register(envelope);
envelope.dotNet = false;//由于是.net开发的webservice,所以这里要设置为true
envelope.setOutputSoapObject(request); final HttpTransportSE httpTransportSE = new HttpTransportSE(WSDL_URI);
httpTransportSE.debug = true;
FutureTask<List<String>> task = new FutureTask<List<String>>(new Callable<List<String>>() { @Override
public List<String> call() throws Exception {
//call web services
httpTransportSE.call(soapAction, envelope);
if(envelope.getResponse() != null){
------------------------这里我传入了参数"ab砂石c",但是envelope.getResponse()的值为 你的名字:null,参数并没有执行???
------------------------webservice 代码:
import java.sql.CallableStatement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;import javax.jws.WebService;
import javax.xml.ws.Endpoint;@WebService(endpointInterface="webservice.WebServiceI")
//@SOAPBinding(style = SOAPBinding.Style.RPC)
public class WebServiceImpl implements WebServiceI {
@Override
public String soa(String name) {
// TODO Auto-generated method stub
System.out.println("测试调用");
return ("你的名字:" + name);
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:8088/DailyRpt/WebServiceImpl", new WebServiceImpl());
System.out.println("service success !");
}
}
-------android引入了 ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar
String WSDL_URI = "http://192.168.122.52:8080/DailyRpt/webservice?WSDL";
String namespace = "http://webservice/";
final String methodName = "soa";//要调用的方法名称
//可能是namspace+method拼接
final String soapAction = "http://webservice/soa";
SoapObject request = new SoapObject(namespace, methodName);
request.addProperty("name", "ab砂石c"); //创建SoapSerializationEnvelope 对象,同时指定soap版本号(之前在wsdl中看到的)
final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11); envelope.bodyOut = request;//由于是发送请求,所以是设置bodyOut
(new MarshalBase64()).register(envelope);
envelope.dotNet = false;//由于是.net开发的webservice,所以这里要设置为true
envelope.setOutputSoapObject(request); final HttpTransportSE httpTransportSE = new HttpTransportSE(WSDL_URI);
httpTransportSE.debug = true;
FutureTask<List<String>> task = new FutureTask<List<String>>(new Callable<List<String>>() { @Override
public List<String> call() throws Exception {
//call web services
httpTransportSE.call(soapAction, envelope);
if(envelope.getResponse() != null){
------------------------这里我传入了参数"ab砂石c",但是envelope.getResponse()的值为 你的名字:null,参数并没有执行???
------------------------webservice 代码:
import java.sql.CallableStatement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;import javax.jws.WebService;
import javax.xml.ws.Endpoint;@WebService(endpointInterface="webservice.WebServiceI")
//@SOAPBinding(style = SOAPBinding.Style.RPC)
public class WebServiceImpl implements WebServiceI {
@Override
public String soa(String name) {
// TODO Auto-generated method stub
System.out.println("测试调用");
return ("你的名字:" + name);
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:8088/DailyRpt/WebServiceImpl", new WebServiceImpl());
System.out.println("service success !");
}
}
-------android引入了 ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar
谢谢!
@WebService
//@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface WebServiceI {
//测试
@WebMethod
@WebResult(name="result")
String getRptByDate(@WebParam(name="sDate")String sDate, @WebParam(name="eDate")String eDate) throws Exception;