覆盖Glassfish生成的WSDL服务端点地址 [英] Override Glassfish Generated WSDL Service Endpoint Address

查看:198
本文介绍了覆盖Glassfish生成的WSDL服务端点地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由wsgen通过maven生成的Web服务。当我将服务部署到Glassfish时,它将服务器URL放置到WSDL中。我们的Glassfish服务器由一个Apache代理服务器。



这意味着什么是当有人访问我们的WSDL并查看服务端点和它们看到的soap地址位置

  http://应用服务器网址/服务... 


$ b b

而不是

  http:// proxy server url / service ... 

我想我需要对一些项目做一些澄清...


  1. 这个端点地址很重要吗?如果端点地址与它们将调用以调用服务的代理服务器的URL不匹配,则客户端仍然能够运行。这基本上问了问题



    UPDATE:为回应此第一个问题,它显示 WSDL到Web服务作为接口是对象。在WSDL中指定的端点地址不重要。实际上,在与WSDL中指定的端点不同的端点上调用Web服务操作相对微不足道。

     
    //从生成的Service类创建服务和代理。
    HelloService service = new HelloService();
    HelloPort proxy = service.getHelloPort();

     
    //覆盖端点地址
    ((BindingProvider)proxy).getRequestContext()。put(
    BindingProvider。 ENDPOINT_ADDRESS_PROPERTY,
    http:// new / endpointaddress );
    proxy.sayHello(Hello World!);



  2. 当我们部署到Glassfish时,WSDL会自动生成。有一个简单的方法来通过应用程序服务器设置覆盖Glassfish中生成的端点地址。如果是,我可以创建一个设置,自动将代理服务器URL放入生成的WSDL。


确实很重要,我们不能用任何方式覆盖它2,那么它基本上意味着我们需要为开发和生产单独的构建。这不是感觉正确,因为它似乎在我看来唯一需要做的部署到另一个服务器是一个现有的(和测试)战争从一个环境到新的服务器。


c> 服务器名称参数

解决方案

/ code>部署服务。您可以从Glassfish管理控制台指定此值,Glassfish将使用此名称,而不是请求URL中的主机名。不幸的是,如果您的应用服务器和代理服务器不使用相同的端口或协议(http到https),此参数将不允许您覆盖端口或协议(我们的't)。



我所做的是为我的服务编写一个简单的servlet过滤器


I have a web service generated by wsgen through maven. When I deploy the service to Glassfish it places the server URL into the WSDL. Our Glassfish server is fronted by an Apache proxy server.

What this all means is when someone accesses our WSDL and looks at the service endpoint and the soap address location they see is

http://app server url/service...

instead of

http://proxy server url/service...

I guess I need some clarification on a few items...

  1. Is this endpoint address important? Will clients still be able to function if the endpoint address does not match the URL of the proxy server they will be calling to invoke the service. This basically asks the questions "is WSDL to web service as interface is to object".

    UPDATE: In response to this first question it does appear that "WSDL to web service as interface is to object". The endpoint address specified in the WSDL is not important. In fact, it is relatively trivial to invoke a web service operation on a different endpoint than the one specified in the WSDL as described here.

    // Create service and proxy from the generated Service class.
    HelloService service = new HelloService();
    HelloPort proxy = service.getHelloPort();
    

    // Override the endpoint address
    ((BindingProvider)proxy).getRequestContext().put(
            BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
            "http://new/endpointaddress");
    proxy.sayHello("Hello World!");
    

  2. The WSDL is generated automatically when we deploy to Glassfish. Is there an easy way to override this generated endpoint address in Glassfish through an app server setting. If so, I can create a setting to automatically place the proxy server URL into the generated WSDL.

If 1 is indeed important and we can't override it in any way with 2, then it basically means we'll need to do separate builds for development and production. This does not "feel right" as it seems to me the only thing we should need to do to deploy to another server is drop an existing (and tested) war from one environment onto the new server.

解决方案

It turns out there is a Server Name parameter on the HTTP Listener where the service is deployed. You can specify this value from the Glassfish administration console and Glassfish will use this name rather than the host name in the request URL.

Unfortunately, this parameter will not allow you to override the port or protocol (http to https) if your app server and proxy server do not use the same ones (ours don't).

What I did instead was write a simple servlet filter for my service to handle this for me.

这篇关于覆盖Glassfish生成的WSDL服务端点地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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