关于webService发布的wsdl中的import问题解决
大家都知道jdk1.6及以后都支持了对webService的原生态的支持;它在发布时会生成一个wsdl和一个xsd(一个类只生成一个xsd)所以就保留了引用关系,如下:
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://jaxws.zzz/jaxws/hello" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://jaxws.zzz/jaxws/hello" name="HelloService">
- <types>
- <xsd:schema>
<xsd:import namespace="http://jaxws.zzz/jaxws/hello" schemaLocation="http://localhost:8080/services/HelloService?xsd=1" />
</xsd:schema>
</types>
- <message name="sayHello">
<part name="parameters" element="tns:sayHello" />
</message>
- <message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse" />
</message>
- <portType name="HelloService">
- <operation name="sayHello">
<input message="tns:sayHello" />
<output message="tns:sayHelloResponse" />
</operation>
</portType>
- <binding name="HelloServicePortBinding" type="tns:HelloService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="sayHello">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="HelloService">
- <port name="HelloServicePort" binding="tns:HelloServicePortBinding">
<soap:address location="http://localhost:8080/services/HelloService" />
</port>
</service>
</definitions>
但是由于osb平台目前不能识别这种引用关系,即所有引用都应该在一个文件中可见;为了解决这个问题:可以采用的方法就是手动把生成的这两个文件(wsdl和xsd文件)手动合并成一个文件比如取名"HelloService.wsdl”;把文件放到classpath路径下,或者发布webService需要的地方,然后在发布webService之前,修改webservice的定义;退如下:
@WebService(serviceName = "HelloService", portName = "HelloServicePort", targetNamespace = "http://jaxws.zzz/jaxws/hello",wsdlLocation="HelloService.wsdl")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class HelloService {
@WebMethod
public String sayHello(String s) {
System.out.println("hello," + s);
return s;
}
}
添加“wsdlLocation="HelloService.wsdl" ”;这个就可以了;
得到结果将是:
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://jaxws.zzz/jaxws/hello" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://jaxws.zzz/jaxws/hello" name="HelloService">
- <types>
- <xs:schema xmlns:tns="http://jaxws.zzz/jaxws/hello" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://jaxws.zzz/jaxws/hello">
<xs:element name="sayHello" type="tns:sayHello" />
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse" />
- <xs:complexType name="sayHello">
- <xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="sayHelloResponse">
- <xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
- <message name="sayHello">
<part name="parameters" element="tns:sayHello" />
</message>
- <message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse" />
</message>
- <portType name="HelloService">
- <operation name="sayHello">
<input message="tns:sayHello" />
<output message="tns:sayHelloResponse" />
</operation>
</portType>
- <binding name="HelloServicePortBinding" type="tns:HelloService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="sayHello">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="HelloService">
- <port name="HelloServicePort" binding="tns:HelloServicePortBinding">
<soap:address location="http://localhost:8080/services/HelloService" />
</port>
</service>
</definitions>
对于另一种import问题就是当我们定义一个接口一个实现类的时候,如果两个接口和实现类不一个package中时,也会出现对wsdl的引用问题,此时只需要在实现类的annotation中添加endpointInterface="com.zzz.jaxws.service.HelloService"(即接口类包路径名);
参考:http://stackoverflow.com/questions/16030574/jax-ws-has-xsd-schema-in-different-url(不过我不得不声名其实拼wsdl文件这个方法我也想到了,只是还没有来得及去试试就先看了这个文章,嘿嘿)
关于webService发布的wsdl中的import问题解决的更多相关文章
- cxf WebService设置wsdl中soapAction的值
用cxf开发一个WebService很简单,只需要下面几步: 1.定义接口 public interface HelloService { String hello(); } 2.实现 public ...
- 如何在VS2013创建WebService并在IIS中发布
第一步:打开VS2013,选择文件->新建->项目. 第二步:选择[ASP.net 空web应用程序],将其命名为自己想的工程名称. 第三步:然后右键点击工程,添加->web服务.然 ...
- webservice发布服务:CXF及客户端调用
2.CXF:(与spring整合) CXF相对来说操作没有AXIS繁琐 1.导入spring的jar包和cxf的jar包 2.在spring的核心配置文件中配置发布的接口类 <?xml vers ...
- 开发基于CXF的 RESTful WebService web 项目 webservice发布
配置步骤 开发基于CXF的 RESTful WebService 1.创建Web项目并导入CXF的jar 2.在Web.xml中配置 CXFServlet <servlet> <se ...
- WebService核心之WSDL深入详解
WebService核心之WSDL深入详解 根据上一篇文章开发的Web Service实例生成的WSDL文档如下: XML里两个属性介绍: targetNamespace 相当于ja ...
- axis2 webservice 发布、调用与项目集成
发布 1.在apache官网下载axis2包,下载Binary Distribution和War Distribution两个zip. 2.将war放入tomcat webapps下部署.并输入 ht ...
- WebService发布协议--SOAP和REST的区别
HTTP是标准超文本传输协议.使用对参数进行编码并将参数作为键值对传递,还使用关联的请求语义.每个协议都包含一系列HTTP请求标头及其他一些信息,定义客户端向服务器请求哪些内容,服务器用一系列HTTP ...
- 基于PI的Webservice发布实例
[转自http://blog.csdn.net/yin_chuan_lang/article/details/6706816] 最近的项目中,接口较多,而Webservice技术是主要实现方式之一.下 ...
- 面向接口的webservice发布方式
import javax.jws.WebService; /**面向接口的webservice发布方式 */ @WebService public interface JobService { pub ...
随机推荐
- 【NOI2014】起床困难综合症(贪心)
[NOI2014]起床困难综合症(贪心) 题面 Description 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚 ...
- data数据不一致的问题
经常会遇到that.data能打印出来(能访问到),而that.data.xxx不能打印(为空)的情况.特别是在调用了云方法,然后setData的时候,为什么会出现这样的情况不明. 解决方法,将需要用 ...
- lambda表达式Expression<Func<Person, bool>> 、Func<Person, bool>区别
前言: 自己通过lambda表达式的封装,将对应的表达式转成字符串的过程中,对lambda表达式有了新的认识 原因: 很多开发者对lambda表达式Expression<Func<Pers ...
- Redis 安装简介
Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用.它提供了Jav ...
- oracle sql model从句demo
model从句作用 sql model可以完成像EXCEL工作表的数据内容扩展.计算填充的功能 关键词解释 partition 分区关键词,白话就是分组 dimension 度量关键词,白话就是要取出 ...
- 理解Spring中的IOC和AOP
我们是在使用Spring框架的过程中,其实就是为了使用IOC,依赖注入和AOP,面向切面编程,这两个是Spring的灵魂. 主要用到的设计模式有工厂模式和代理模式 IOC就是典型的工厂模式,通过ses ...
- 修改UI及盒子启动及部分后续操作
服务器操作: 1.配置nfs: # vim /etc/exports /home/nfsroot *(insecure,rw,no_root_squash) mkdir -pv /home/nfsro ...
- Java 面试宝典-2017
http://www.cnblogs.com/nelson-hu/p/7190163.html Java面试宝典-2017 Java面试宝典2017版 一. Java基础部分........... ...
- MySQL数据库学习三 数据库对象和基本操作
3.1 数据库和数据对象 1. 系统数据库 information_schema:主要存储系统中的一些数据库对象信息,如用户列表信息.列信息.权限信息.字符集信息和分区信息等. performance ...
- Django+xadmin打造在线教育平台(六)
九.课程章节信息 9.1.模板和urls 拷贝course-comments.html 和 course-video.html放入 templates目录下 先改course-video.html,同 ...