Weblogic11g+Axis1.4 实现WebService服务
IDE:NetBeans8.0
项目结构:

(1)新建接口Hello.java
package com.test; /**
* @author y
* @date 2015-9-5 7:51:29
* @version 1.0
* @desc
*/
public interface Hello { String sayHello(String name);
}
(2)新建实现类HelloManager.java
package com.test; /**
* @author y
* @date 2015-9-5 7:51:59
* @version V1.0
* @desc
*/
public class HelloManager implements Hello{ public String sayHello(String name) {
return "Hello,"+name;
} }
(3)配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener> <servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet> <servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<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>
<!--/services/*-->
<url-pattern>/*</url-pattern>
</servlet-mapping> <session-config>
<!-- Default to 5 minute session timeouts -->
<session-timeout>5</session-timeout>
</session-config> <!-- currently the W3C havent settled on a media type for WSDL;
http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
for now we go with the basic 'it's XML' response -->
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping> <mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping> <welcome-file-list id="WelcomeFileList">
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list> </web-app>
(4)新建server-config.wsdd
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<handler type="java:org.apache.axis.handlers.http.URLMapper" name="URLMapper"/> <service name="HelloManagerServices" provider="java:RPC">
<parameter name="className" value="com.test.HelloManager"/>
<parameter name="allowedMethods" value="*"/>
</service> <transport name="http">
<requestFlow>
<handler type="URLMapper"/>
</requestFlow>
</transport>
</deployment>
成功部署之后访问:http://localhost:7001/ws01/HelloManagerServices?wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:7001/ws01/HelloManagerServices" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:7001/ws01/HelloManagerServices" xmlns:intf="http://localhost:7001/ws01/HelloManagerServices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:message name="sayHelloRequest"> <wsdl:part name="name" type="soapenc:string"/> </wsdl:message> <wsdl:message name="sayHelloResponse"> <wsdl:part name="sayHelloReturn" type="soapenc:string"/> </wsdl:message> <wsdl:portType name="HelloManager"> <wsdl:operation name="sayHello" parameterOrder="name"> <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/> <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HelloManagerServicesSoapBinding" type="impl:HelloManager"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="sayHello"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="sayHelloRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://test.com" use="encoded"/> </wsdl:input> <wsdl:output name="sayHelloResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:7001/ws01/HelloManagerServices" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HelloManagerService"> <wsdl:port binding="impl:HelloManagerServicesSoapBinding" name="HelloManagerServices"> <wsdlsoap:address location="http://localhost:7001/ws01/HelloManagerServices"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
客户端测试:
public static void main(String[] args) throws Exception {
String namespace="http://test.com";
String method="sayHello";
String wsdl="http://localhost:7001/ws01/HelloManagerServices";
Object[] params={"yshyee"};
String result = AxisInvokeJAXWSUtil.invoke(namespace, method, wsdl, params);
System.out.println("=======result:"+result);
}
AxisInvokeJAXWSUtil.java
public final class AxisInvokeJAXWSUtil {
/**
*
* @param namespace
* @param method
* @param wsdl
* @param params
* @return
* @throws Exception
*/
public static String invoke(String namespace, String method, String wsdl, Object[] params) throws Exception{
Object obj;
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(namespace, method));
call.setTargetEndpointAddress(wsdl);
if (null != params) {
int len = params.length;
for (int i = 0; i < len; i++) {
//动态设置参数,而且参数类为字符串类型
call.addParameter("arg" + i, XMLType.XSD_STRING, ParameterMode.IN);
}
if (len > 0) {
//设置返回值类型为字符串类型
call.setReturnType(XMLType.XSD_STRING);
}
} else {
params = new Object[]{};
}
obj = call.invoke(params);
return obj == null ? "" : obj.toString();
}
}
Weblogic11g+Axis1.4 实现WebService服务的更多相关文章
- axis1.4开发webservice服务端(快速入门)-基于jdk1.4
写在前面: 现在有很多开发webservice的方法以及框架,什么cxf等,但是这些在你编写服务类的时候都要用到注解这个功能.如果现在的jdk是1.4的,那么就不能使用注解这个功能了.所以这里可以用到 ...
- 基于axis1.4的webservice实例
1.准备工作: 概念:SOAP(简单对象访问协议).WSDL(web服务描述语言).XML(可扩展标记语言).axis(阿帕奇可扩展交互系统) (1) 下载axis1.4,将axis1.4中的 ...
- Axis1.4开发webservice个人笔记
Axis1.4开发webservice SOAP 是基于 XML 的简易协议,SOAP 即Simple Object Access Protocol(简单对象访问协议),可使应用程序在 HTTP 之上 ...
- 基于Axis1.4的webservice接口开发(接口调用)
基于Axis1.4的webservice接口开发(接口调用) 一.webservice接口代码参考上一篇博客: http://www.cnblogs.com/zhukunqiang/p/7125668 ...
- 基于Axis1.4的webservice接口开发(代码开发)
基于Axis1.4的webservice接口开发(代码开发) 一.开发环境: 我的开发环境是MyEclipse 2015+Apache-Tomcat-8.0.21. 二.代码开发: 1.新建一个Web ...
- 使用axis1.4生成webservice的客户端代码
webservice服务端: https://blog.csdn.net/ghsau/article/details/12714965 跟据WSDL文件地址生成客服端代码: 1.下载 axis1.4 ...
- 【Java EE 学习 80 下】【调用WebService服务的四种方式】【WebService中的注解】
不考虑第三方框架,如果只使用JDK提供的API,那么可以使用三种方式调用WebService服务:另外还可以使用Ajax调用WebService服务. 预备工作:开启WebService服务,使用jd ...
- WebService学习总结(四)——调用第三方提供的webService服务
http://www.cnblogs.com/xdp-gacl/p/4260627.html 互联网上面有很多的免费webService服务,我们可以调用这些免费的WebService服务,将一些其他 ...
- webservice服务的简单应用
本人目前刚接触到webservice服务,知道它是一个为外部提供接口的服务,下面大概讲一下webservice是如何应用的. 在此我只针对ASP.NET 讲一个是如何应用的: 1. 打开VS ,在WE ...
随机推荐
- ganglia Web前端清除当机节点
ganglia默认如果服务器down机也不会在web前段清除该设备,官方文档介绍的办法如下: 1. 登录中央gmeta和gmond机器 2. vi gmond.conf,修改如下,host_dmax默 ...
- DCL双检查锁机制实现的线程安全的单例模式
public class MyObject { private volatile static MyObject myObject; private MyObject(){} public stati ...
- Android的TextView与Html相结合的用法
Android中的TextView,本身就支持部分的Html格式标签.这其中包括常用的字体大小颜色设置,文本链接等.使用起来也比较方便,只需要使用Html类转换一下即可.比如: textView.se ...
- 高性能MySql进化论(九):查询优化器常用的优化方式
1 介绍 1.1 处理流程 当MYSQL 收到一条查询请求时,会首先通过关键字对SQL语句进行解析,生成一颗“解析树”,然后预处理器会校验“解析树”是否合法(主要校验数据列和表明 ...
- POJ2250:Compromise(LCS)
Description In a few months the European Currency Union will become a reality. However, to join the ...
- Python开发【第七篇】:面向对象 和 python面向对象进阶篇(下)
Python开发[第七篇]:面向对象 详见:<Python之路[第五篇]:面向对象及相关> python 面向对象(进阶篇) 上一篇<Python 面向对象(初级篇)> ...
- js 实现关键词球状旋转效果
效果图 html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
- js原生封装自定义滚动条
/* * @Author: dothin前端 * @Date: 2015-11-21 00:12:15 * @Last Modified by: dothin前端 * @Last Modified t ...
- My.Ioc 代码示例——利用 ObjectBuilderRequested 事件实现延迟注册
在使用 Ioc 框架时,一般我们建议集中在一个称为 Composition Root(其含义请参见下面的小注)的位置来注册 (Register) 和解析 (Resolve) 服务.这种做法的目的在于限 ...
- 开源的Android开发框架-------PowerFramework使用心得(三)内置浏览器BrowserActivity
使用内置浏览器必须是引用源码的方式(因为jar中不能打包布局文件等资源).内置浏览器是一个继承自BaseActivity的普通Activity,使用WebView实现. 1.简单的打开内置浏览器 In ...