日期:2014-05-17  浏览次数:20715 次

webservice参数传递
webservice有两个应用 A应用和B应用A应用提供webservice接口。。 B应用调用A应用的接口, 然后插入数据到A应用中(数据是从B中查询得到的),想请问下A应用是怎么接受数据的。
是用的axis2
这是客户端(同上的B应用)
package client;

import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;


public class StudentRPCClient {

/**
 * @param args
 * @throws AxisFault 
 */
public static void main(String[] args) throws Exception {

RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/StudentService");
//EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/StudentService");
options.setTo(targetEPR);

// QName opAddEntry = new QName("http://ws.apache.org/axis2", "getAllStudent");
// String[] strArray = (String[]) serviceClient.invokeBlocking(opAddEntry, new Object[]{}, new Class[]{String[].class})[0];
//
// for (String s : strArray) 
// {
// String[] array = s.split(",");
// for(String ss: array) System.out.print("<" + ss + "> "); System.out.println(); 
// }

System.out.println();
Class[] classes=new Class[]{String.class};
QName opAddEntry = new QName("http://ws.apache.org/axis2", "insertUser");
System.out.println(serviceClient.invokeBlocking(opAddEntry,new Object[]{},classes)[0]);
}

}


这是服务端(同上A应用)
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpRequest;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.params.HttpParams;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

import conn.GetAllStu;
import data.Student;



public class StudentService{

// public int end=1;
// public String[] getAllStudent()
// {
// GetAllStu getStu=new GetAllStu();
// List<Student> list=getStu.getAllStudent();
// int num=Integer.valueOf(list.size());
// String[] str=new String[num];
// for(int i=0;i<list.size();i++)
// {
// str[i]=String.valueOf(list.get(i).getId())+","+list.get(i).getName()+","+list.get(i).getAddress();
// }
// return str;
// }


public String insertUser() throws SQLException
{

String userName="";
String password="";
String user="root";
String pass="";
String url="jdbc:mysql://localhost:3306/xindou_db";
&nb