使用 Jax-WS Endpoint 发布 WS [英] Publishing a WS with Jax-WS Endpoint

查看:48
本文介绍了使用 Jax-WS Endpoint 发布 WS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个最小的 Web 服务并使用 javax.xml.ws.Endpoint 发布它.如果我尝试在以下位置获取 WSDLhttp://localhost:1234/AddService?wsdl 工作正常.

I built a minimal web service and published it using javax.xml.ws.Endpoint. If I try to get the WSDL at http://localhost:1234/AddService?wsdl it works fine.

试图在 http://192.168.0.133:1234/AddService?wsdl 接收它,我没有收到任何东西.这个地址和localhost一样.

Trying to recieve it at http://192.168.0.133:1234/AddService?wsdl, I don't receive anything. This address is the same as localhost.

是否有可能在不提供地址的情况下发布网络服务?

Is there a posibiility to publish a webservice without providing the address?

package test;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class AddService {

    @WebMethod
    public int add(int a, int b){
        return a+b;
    }

    public static void main(String[] args ){
        Endpoint.publish("http://localhost:1234/AddService", new AddService());
    }
}

修改代码为

Endpoint.publish("http://192.168.0.133:1234/AddService", new AddService());

为我获取 IP 地址上的 wsdl,而不是本地主机上的 wsdl.

gets me the wsdl on the IP address but not on localhost.

难道不能只定义端口吗?

Isn't there a posibility to just define the port?

推荐答案

你能试试在 0.0.0.0 上发布吗?

Could you try publishing it on 0.0.0.0?

这篇关于使用 Jax-WS Endpoint 发布 WS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆