문제

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.

도움이 되었습니까?

해결책

진행률 표시 줄에서 다음 Paint 이벤트가 발생하면 레이블이 지워지는 백분율 레이블이 발생할 수 있습니다.사용자 컨트롤로 진행률 표시 줄을 구현하면 OnPaint 메서드를 무시하고 그곳에서 텍스트를 렌더링 할 수 있습니다 (base.OnPaint(e) 후).
나는 당신의 상황을 시뮬레이트하기 위해 몇 가지 간단한 수업을 만들었습니다.다음은 나를 위해 일하는 접근 방식입니다.

1) 진행률 막대 제어 (간단한 구현, onPaint로 기본 아이디어를 개략적으로 개요) :

public partial class CustomProgressBar : UserControl
{
    public int Percentage { get; set; }

    public CustomProgressBar()
    {
        InitializeComponent();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics g = e.Graphics;
        Rectangle bounds = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);

        // Paint a green bar indicating the progress.
        g.FillRectangle
        (
            Brushes.LimeGreen,
            new Rectangle
            (
                bounds.X,
                bounds.Y,
                (int)(bounds.Width * Percentage / 100.0),
                bounds.Height
            )
        );

        // Draw a black frame around the progress bar.
        g.DrawRectangle(Pens.Black, bounds);

        // Draw the percentage label.
        TextRenderer.DrawText(g, Percentage + "%", Font, bounds, ForeColor);
    }
}
.

2) 백그라운드 스레드에서 실행되는 작업을 나타내는 클래스 :

public class BackgroundJob
{
    public event Action<object, int> StepCompleted;

    public void Execute()
    {
        const int TotalSteps = 10;
        for (int step = 1; step <= TotalSteps; step++)
        {
            // Execute some heavy work here.
            Thread.Sleep(1000);

            // Calculate percentage (0..100).
            int percentage = (int)(step * 100.0 / TotalSteps);

            // Notify the subscribers that the step has been completed.
            OnStepCompleted(percentage);
        }
    }

    protected virtual void OnStepCompleted(int percentage)
    {
        if (StepCompleted != null)
        {
            StepCompleted(this, percentage);
        }
    }
}
.

3) 양식 클래스.사용자 정의 진행률 막대 제어가 포함되어 있으며 버튼을 누를 때 백그라운드 작업을 시작합니다.

public partial class MainForm : Form
{
    public MainForm()
    {
        InitializeComponent();
    }

    private void btnStartJob_Click(object sender, EventArgs e)
    {
        Thread backgroundThread = new Thread
        (
            () =>
            {
                var job = new BackgroundJob();
                job.StepCompleted += job_StepCompleted;
                job.Execute();
            }
        );
        backgroundThread.Start();
    }

    private void job_StepCompleted(object sender, int percentage)
    {
        progressBar.Percentage = percentage;

        // Force the progress bar to redraw itself.
        progressBar.Invalidate();
    }
}
.

Invalidate() 내부적으로 (generacodicicetagcode 속성 세터 내부), 그림 프로세스가 어떻게 트리거되는지 강조하기 위해 별도로 호출합니다.

다른 팁

I discovered what I consider to be a very simple way to deal with the issue: use mod_substitute in Apache. Since those of us with this problem are already using Apache, and it's built in and simple, I liked this approach best.

I put a block similar to the below in one of my Apache conf files and found joy:

<Location />
   AddOutputFilterByType SUBSTITUTE text/xml
   Substitute "s|http://internal:8080/xxx|https://external/xxx|ni"
</Location>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top