如何把把webService整理成java接口文档生成工具描述文档

1。配置XML文件,如果新建一个XML文件需要在applicationContext.xm里面配置一下
&import resource="cxf-client.xml" /&
&import resource="cxf-hand.xml" /&
&import resource="applicationContext-gxpc.xml" /&
2。新建一个XML,xml文件模板如下:
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd"&
&!--验证单点登录令牌--&
&jaxws:client id="ISSOService" address="http://172.16.7.107:9090/com.kutesmart.esb.ldap.sso?wsdl"           serviceClass="com.kutesmart.bl.soap.cxf.ldap.ISSOService"&
&/jaxws:client&
3。上面的xml文件中的 serviceClass ="com.kutesmart.bl.soap.cxf.ldap.ISSOService",需要在此目录下新建的service类,这个类把wsdl2Java转换出来的源文件接口文件ISSOService.java里面的内容需要的复制出来就好,其中
@XmlSeeAlso({
ObjectFactory.class
  删除就好。
配置这些地方就可以了,然后在 其他类中new一个ISSOService对象传入相应的参数就可以调用这个webservice接口了。
这是第一次适用调用web service接口,这只是一个简单的方式,这是我自己弄出来得,肯定还有很多,看起来还是很简单的, 但是对于新手来说,很多东西是不知道,百度都不知道百度什么,希望这篇能帮助到菜鸟们。我也是菜鸟
阅读(...) 评论()webservice如何发布接口中的部分方法 - ITeye问答
我的接口中有好多方法,但只想发布其中一个,如何设置。
在你要发布的方法处加一个:
@WebMethod
应该可以的。
@WebMethod(exclude=true)
如果你用的是cxf的话照样可以。不过是要定义一个java interface了
下面将给你一个例子:
//这个是接口
package org.iteye.bbjava.ws.
import javax.jws.WebS
@WebService
public interface HelloService {
String sayHi(String text);
现面是实现类:
package org.iteye.bbjava.ws.service.
import javax.jws.WebS
import org.iteye.bbjava.ws.service.HelloS
@WebService(endpointInterface = "org.iteye.bbjava.ws.service.HelloService")
public class HelloServiceImpl implements HelloService {
public String sayHi(String text) {
System.out.println("sayHi called");
return "Hello " +
下面是与spring 整合的配置:
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&
&import resource="classpath:META-INF/cxf/cxf.xml" /&
&import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&
&jaxws:endpoint id="helloService" implementor="#hello"
address="/HelloServiceImpl" /&
&bean id="hello" class="org.iteye.bbjava.ws.service.impl.HelloServiceImpl" /&
web.xml的代码:
&?xml version="1.0" encoding="UTF-8"?&
&web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="/xml/ns/javaee" xmlns:web="/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="/xml/ns/javaee /xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&
&display-name&ws-spring&/display-name&
&welcome-file-list&
&welcome-file&index.html&/welcome-file&
&welcome-file&index.htm&/welcome-file&
&welcome-file&index.jsp&/welcome-file&
&welcome-file&default.html&/welcome-file&
&welcome-file&default.htm&/welcome-file&
&welcome-file&default.jsp&/welcome-file&
&/welcome-file-list&
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&WEB-INF/applicationContext.xml&/param-value&
&/context-param&
&listener&
&listener-class&
org.springframework.web.context.ContextLoaderListener
&/listener-class&
&/listener&
&servlet-name&CXFServlet&/servlet-name&
&servlet-class&
org.apache.cxf.transport.servlet.CXFServlet
&/servlet-class&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&CXFServlet&/servlet-name&
&url-pattern&/*&/url-pattern&
&/servlet-mapping&
&/web-app&
如果想更清楚请看:[url]/blog/1344684[/url]
jsr181& ,里面提供的注释,就是用来减少对xml文件的修改 ,比如 在& 某个方法前面加 @WebMethod 注释 ,然后在 services.xml
文件中添加&serviceClass&你的服务程序类&/serviceClass&
&serviceFactory&jsr181&/serviceFactory&
发布的时候就就会生成你所注释的那个方法,而你没有注释的就不会在wsdl里出现
要发布的那个方法定义为public,其他不要发布的定义为private?
你问的好笼统& 你是用什么方式发布的webservice 各种有各种不同的方式& spring里面貌似有webservice的插件& 直接给代理类的方法上面加注解就可以发布了
已解决问题
未解决问题博客分类:
在大多数情况下我们都需要为我们的服务提供一个WSDL文件,而 Axis2's Java2WSDL 是专门用来生成WSDL文件的D专用工具,如果你要在命令行模式下进行生成WSDL文件,首先需要保证你的环境变量AXIS2_HOME是否已经配置OK,同时还要保证把%AXIS2_HOME%\bin加入到你的path环境中,要生成 WSDL文件,首先要保证你的class能够编译成功,而且已经编译成功,然后进入class文件编译后的根目录(在JBuilder中是classes,在Eclipse中是bin目录)这时,生成WSDL文件的准备工作已经OK。
下面是生成WSDL文件时的可选参数和参数说明:
---------------------------------------------------------------------------------Usage java2wsdl -cn &fully qualified class name& : class file name
-o &output Location& : output file location
-cp &class path uri& : list of classpath entries - (urls)
-tn &target namespace& : target namespace
-tp &target namespace prefix& : target namespace prefix
-stn &schema target namespace& : target namespace for schema
-stp &schema target namespace prefix& : target namespace prefix for schema
-sn &service name& : service name
-of &output file name& : output file name for the WSDL
-st &binding style& : style for the WSDL
-u &binding use& : use for the WSDL
-l &soap address& : address of the port for the WSDL
-nsg &generator class name& : fully qualified name of the class that implements NamespaceGenerator
-p2n [&java package&,&namespace] [&java package&,&namespace]... : java package to namespace mapping for argument and return types...to assign all types to a single namespace : -p2n [all , &namespace&] ...
-efd &qualified/unqualified& : Setting for elementFormDefault (defaults to qualified)
-afd &qualified/unqualified& : Setting for attributeFormDefault (defaults to qualified)
-xc &extra class& : Extra class for which schematype must be generated.
Use as : -xc class1 -xc class2 ...
典型地,进入你的工程的二进制编译根目录,执行命令模板如下:
java2wsdl -cp . -cn [PACKAGENAME].[CLASSNAME]-of [FILENAME].wsdl
现在我们假设在samples.helloworld.service.包下面有个HelloWorldService类,工程的类文件编译后存放在build\classes目录下,那么,首先进入该目录中,然后执行以下命令:
java2wsdl -cp . -cn samples.helloworld.service.axiom.HelloWorldService -of HelloWorldService.wsdl
执行后的CMD提示如下说明已经成功执行了:
Using AXIS2_HOME:
D:\axis2-1.1.1 Using JAVA_HOME:
C:\Program Files\Java\jdk1.5.0_06
浏览 17623
浏览: 277239 次
来自: 西安
最好这样:java -Xms3700M -Xmx3700M - ...
学习一哈……
System.out.println(&开始注册Js ...
你的头像看起来很像我们宿舍老四。。。
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix' 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
web service协议的开发接口文档_通用短信平台Webservice使用说明
下载积分:1500
内容提示:web service协议的开发接口文档_通用短信平台Webservice使用说明
文档格式:DOC|
浏览次数:791|
上传日期: 01:14:05|
文档星级:
全文阅读已结束,如果下载本文需要使用
 1500 积分
下载此文档
该用户还上传了这些文档
web service协议的开发接口文档_通用短信平台Webservi
关注微信公众号

我要回帖

更多关于 postman 生成接口文档 的文章

 

随机推荐