<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEweb-appPUBLIC"-//SunMicrosystems,Inc.//DTDWeb
Application2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-AxisServlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>AxisAdminServlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<display-name>SOAPMonitorService</display-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services
package test.com.sinosoft.webservice;
import java.io.IOException;
import java.net.MalformedURLException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class TestHelloService {
private static final Log log = LogFactory.getLog(TestHelloService.class);
private static final String HELLO_SERVICE_ENDPOINT = "http://127.0.0.1:8080/WebServiceTest/services/HelloServices?wsdl";
public static void main(String[] args) {
TestHelloService tester = new TestHelloService();
// tester.callSayHello();
tester.callSayHelloToPerson();
}
public void callSayHello() {
try {
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(
HELLO_SERVICE_ENDPOINT));
//下面名字查询的http://127.0.0.1:8080/WebServiceTest/services/HelloServices?wsdl文件里有
call.setOperationName(new QName("http://webservice.sinosoft.com/",
"sayHello"));
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
try {
//远程调用发布的方法
String ret = (String) call.invoke(new Object[] {});
System.out.println("The return value is:" + ret);
return;
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
log.error("call sayHello service error!");
}
public void callSayHelloToPerson() {
try {
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(HELLO_SERVICE_ENDPOINT));
call.setOperationName(new QName("http://webservice.sinosoft.com/",
"sayHelloToPerson"));
call.addParameter("name", org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
try {
String ret = (String) call.invoke(new Object[] { "Stephen" });
System.out.println("The return value is:" + ret);
return;
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
log.error("call sayHello service error!");
}
}