【问题标题】:how to define webservice end point url如何定义 Web 服务端点 url
【发布时间】:2016-06-10 14:11:05
【问题描述】:

我是网络服务的新手。我创建了一个具有以下 WSDL 定义的 Web 服务。

 <wsdl:service name="InterfaceService">

    <wsdl:port name="InterfaceSOAP"
        binding="impl1InterfaceSOAP">
        <soap:address
            location="http://localhost:9080/MyWeb/services/MyInterface" />
    </wsdl:port>
 </wsdl:service>

当 Web 服务发布时,Web 服务在 URL http://localhost:9080/MyWeb/InterfaceService 而不是 http://localhost:9080/MyWeb/services/MyInterface URl 上可用。 我们如何更改发布 Web 服务的 URL

【问题讨论】:

  • 这是在 WebSphere Liberty 中还是在 WebSphere Application Server 传统中?

标签: java web-services websphere jax-ws


【解决方案1】:

在传统的 WebSphere Application Server 中

在 web.xml 中使用自定义 url 模式

例如

web.xml

<servlet id="...">
    <servlet-name>mypkg.MyInterface</servlet-name>
    <servlet-class>mypkg.MyInterface</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>mypkg.MyInterface</servlet-name>
    <url-pattern>/services/MyInterface</url-pattern> 
</servlet-mapping>

见官方文档here

在 WebSphere Liberty 中

在 ibm-ws-bnd.xml 中使用一个元素

例如

ibm-ws-bnd.xml

<?xml version="1.0" encoding="UTF-8"?>
<webservices-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd" 
    version="1.0">
    <webservice-endpoint port-component-name="MyInterface" address="/services/MyInterface" />
</webservices-bnd>

见官方文档here

【讨论】:

  • 我要的是 wbsphere 应用服务器。但我认为对于 jax ws,我们不必在 web.xml 中定义服务。是不是如果 v 不定义然后采用默认地址?即使我定义显示的错误是 MyInterface s not a servlet
  • 是的,您可以使用 JAX-WS 注释,据我了解,在部署期间将为您生成默认 web.xml。默认的 URL 模式是 /MyInterface。但是你可以自定义 web.xml,就像我提到的 URL 映射之类的东西。如果您仍然遇到问题,请问:您是否更新了我的 sn-p 中的 以指向您的实际包和类?
  • 是的,我添加了正确的 servlet 类。我对 webservices.xml 中的 xsi:schemalocation 有疑问。我必须为 jax-ws 指定什么版本。当前版本是 1.1。
  • 不确定您正在运行什么版本的 WebSphere 或您正在尝试做什么。你使用的东西有问题吗?但 EE 6 级架构位置信息似乎是:xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_web_services_1_3.xsd"
猜你喜欢
  • 2013-03-12
  • 1970-01-01
  • 1970-01-01
  • 2018-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-20
相关资源
最近更新 更多