大家都知道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问题解决的更多相关文章

  1. cxf WebService设置wsdl中soapAction的值

    用cxf开发一个WebService很简单,只需要下面几步: 1.定义接口 public interface HelloService { String hello(); } 2.实现 public ...

  2. 如何在VS2013创建WebService并在IIS中发布

    第一步:打开VS2013,选择文件->新建->项目. 第二步:选择[ASP.net 空web应用程序],将其命名为自己想的工程名称. 第三步:然后右键点击工程,添加->web服务.然 ...

  3. webservice发布服务:CXF及客户端调用

    2.CXF:(与spring整合) CXF相对来说操作没有AXIS繁琐 1.导入spring的jar包和cxf的jar包 2.在spring的核心配置文件中配置发布的接口类 <?xml vers ...

  4. 开发基于CXF的 RESTful WebService web 项目 webservice发布

    配置步骤 开发基于CXF的 RESTful WebService 1.创建Web项目并导入CXF的jar 2.在Web.xml中配置 CXFServlet <servlet> <se ...

  5. WebService核心之WSDL深入详解

    WebService核心之WSDL深入详解 根据上一篇文章开发的Web Service实例生成的WSDL文档如下: XML里两个属性介绍: targetNamespace          相当于ja ...

  6. axis2 webservice 发布、调用与项目集成

    发布 1.在apache官网下载axis2包,下载Binary Distribution和War Distribution两个zip. 2.将war放入tomcat webapps下部署.并输入 ht ...

  7. WebService发布协议--SOAP和REST的区别

    HTTP是标准超文本传输协议.使用对参数进行编码并将参数作为键值对传递,还使用关联的请求语义.每个协议都包含一系列HTTP请求标头及其他一些信息,定义客户端向服务器请求哪些内容,服务器用一系列HTTP ...

  8. 基于PI的Webservice发布实例

    [转自http://blog.csdn.net/yin_chuan_lang/article/details/6706816] 最近的项目中,接口较多,而Webservice技术是主要实现方式之一.下 ...

  9. 面向接口的webservice发布方式

    import javax.jws.WebService; /**面向接口的webservice发布方式 */ @WebService public interface JobService { pub ...

随机推荐

  1. jquery的各种插件调用(有些已经过时,以备注,其他的一些可以闲的时候用作拆解)

    jquery的valiteDate验证插件应用 <!DOCTYPE html> <html>        < head>            < meta ...

  2. 【BZOJ3680】吊打XXX(模拟退火)

    [BZOJ3680]吊打XXX(模拟退火) 题面 BZOJ 题解 模拟退火... 就是模拟退火 然后这题有毒 各种调参数之后终于\(AC\)了.. 这种题就是玄学呀... 温度要调大 最后跑完还要向四 ...

  3. [BZOJ4372]烁烁的游戏

    题面戳我 题意: 给一颗n个节点的树,边权均为1,初始点权均为0,m次操作: Q x:询问x的点权. M x d w:将树上与节点x距离不超过d的节点的点权均加上w. \(1≤n≤10^5\) sol ...

  4. UOJ207:共价大爷游长沙

    题面 UOJ Sol 神题 给每个点对随机一个权值,把这两个点的权值异或上这个随机的值 用\(LCT\)维护子树信息,若子树异或和为所有点对的异或和那么就是答案 大常数代码 # include < ...

  5. sqlserver的分页语句

    SELECT * FROM ( SELECT *,ROW_NUMBER() OVER (ORDER BY ID asc) AS RowNum FROM qnfh ) AS TWHERE T.RowNu ...

  6. 简简单单把event loop说清楚

    event loop这东西,确实把我坑了一把,面试的时候被问到这个问题的时候,我是懵逼的,完全不知道怎么回答,而当我回来查到原来这个听起来如此玄乎又厉害的名字就是异步和单线程那块的知识的时候,我心情又 ...

  7. 【redis源码阅读】redis对象

    结构定义 在redis中,对象的数据结构定义如下: ​typedef struct redisObject { ​unsigned type:4; ​unsgined encoding:4; ​uns ...

  8. Intel 移位指令的陷阱(转)

    今天发现了一个Intel逻辑左移指令shl的一个bug.   逻辑左移的概念是对给定的目的操作数左移COUNT次,每次移位时最高位移入标志位CF中,最低位补零. 其中OPRD1为目的操作数, 可以是通 ...

  9. Mecanim之IK动画

    序言:IK动画全名是Inverse Kinematics 意思是逆向动力学,就是子骨骼节点带动父骨骼节点运动. 比如体操运动员,只靠手来带动身体各个部位的移动.手就是子骨骼,身体就是它的父骨骼,这时运 ...

  10. 新手立体四子棋AI教程(1)——基础扫盲

    一.引言 最近身边好几个朋友开始玩立体四子棋,激起了我的好奇心.那么首先来说什么是[立体四子棋],规则又是如何呢? 上图即为立体四子棋,规则类似于五子棋四子连在一起,但是四子棋更加多样.丰富.不仅可以 ...