JAVA 웹 서비스 발표 및 호출
5555 단어 webservice
<?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!");
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
java가 클라이언트를 통해 서버 웹 서비스에 접근하는 방법본고는 자바가 클라이언트를 통해 서버 웹 서비스에 접근하는 방법을 실례로 설명한다.다음과 같이 여러분에게 참고할 수 있도록 공유합니다. 자바 관련 내용에 관심이 있는 더 많은 독자들은 본 사이트의 주제를 볼 수 있습...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.