如这样的wsdl: http://cvs.apache.org/viewcvs.cgi/*checkout*/ws-axis/java/samples/addr/AddressBook.wsdl 你生成java类以后只需要写这样的代码: public class Tester { public static void main(String [] args) throws Exception { // Make a service AddressBookService service = new AddressBookServiceLocator();
// Now use the service to get a stub which implements the SDI. AddressBook port = service.getAddressBook();
// Make the actual call Address address = new Address(...); port.addEntry("Russell Butek", address); }} 当然假如你觉得无所谓的话,那么直接写在jsp里面也可以,就是这么简单
但具体怎么在JSP中引用就需要到JSP版问问
GOOD LUCK
这是我写的,请各位指正:
try{
String url="http://xxx.xxx.xxx.xxx:8080/Service1.asmx?WSDL";
Service service = new Service(); Call call = (Call)service.createCall(); call.setTargetEndpointAddress(url); call.setOperationName("UserReg");
//必填的五项
call.addParameter("UserName",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.addParameter("PassWord",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.addParameter("IdNo",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.addParameter("IdType",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.addParameter("NickName",org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true); String ret = (String) call.invoke( new Object[] {} );
out.println("返回值:"+ret);
}catch(Exception e){
out.println(e.toString());
}
http://cvs.apache.org/viewcvs.cgi/*checkout*/ws-axis/java/samples/addr/AddressBook.wsdl
你生成java类以后只需要写这样的代码:
public class Tester
{
public static void main(String [] args) throws Exception {
// Make a service
AddressBookService service = new AddressBookServiceLocator();
// Now use the service to get a stub which implements the SDI.
AddressBook port = service.getAddressBook();
// Make the actual call
Address address = new Address(...);
port.addEntry("Russell Butek", address);
}}
当然假如你觉得无所谓的话,那么直接写在jsp里面也可以,就是这么简单
多谢!急盼!!
这样在就可以调用了,调用方法类似与javabean。
{
URL httpurl = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection)httpurl.openConnection();
httpConn.setRequestMethod( "POST" );
httpConn.setRequestProperty("Host",host);
httpConn.setRequestProperty("Content-Type",contype);
httpConn.setRequestProperty( "Content-Length",String.valueOf(postStr.length()));
httpConn.setRequestProperty("SOAPAction",soapaction);
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
PrintWriter out = new PrintWriter(httpConn.getOutputStream());
out.print(postStr);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
result += inputLine+"\n";
}
in.close();
return result;
}这是我这边调用webservice接口