Skip to Content
avatar image
Former Member

Dynamic Logical Port for Web Service Client

Hi *!

We want to use the same Web Service Client code with different Web Service instances running on different systems. So I need to configure the logical port (especially the URL of the endpoint) dynamically at runtime.

Please give me a hint, how this is done.

(we are using WebAS 6.40 SP7)...

Thanks in advance,

Frank

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jul 14, 2005 at 04:13 AM

    Hi Frank,

    You can set Endpoint of your Webservice model from your code dynamically using following code:

    wdContext.current<Node>Element().modelObject()._setEndPoint("<Your URL>");

    You have to write this code before executing the model for webservice.

    It will set your endpoint dynamically.

    You can also set your username and password for Proxy settings dynamically here.

    Regards,

    Bhavik

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Frank,

      I hope you were able to solve your issue on you own in the meantime.

      I was looking for the answer to this question today. This was the only thread I found on SDN. Unfortunately, it did not contain an answer yet. I was able to figure out a way to set the endpoint address dynamically after searching help.sap.com and after examining the interfaces offered by the Stub (logical port in this case) classes.

      Here's an extract from my code:

      // Connect to JNDI context
      InitialContext ic = new InitialContext();
      
      // Get reference to web service proxy from JNDI context
      Z_MSC_GET_SCHEDULE_WSDService service = 
      	(Z_MSC_GET_SCHEDULE_WSDService) ic.lookup("wsclients/proxies/iot-online.de/msc~srv_ejb~proxy/de.iot_online.msc.proxy.ScheduleReaderProxy");
      
      // Get reference to logical port from web service proxy 
      Z_MSC_GET_SCHEDULE_WSD logicalPort = service.getLogicalPort();
      
      // Set URL of web service Endpoint
      logicalPort._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://<FQDN>:8010/sap/bc/srt/rfc/sap/Z_MSC_GET_SCHEDULE_WSD?sap-client=100");

      This is explained on

      http://help.sap.com/saphelp_nwce10/helpdata/en/45/113a1221337249e10000000a155369/frameset.htm

      You can also set the credentials (username / password) with the method _setProperty.

      Best regards

      Christian

  • avatar image
    Former Member
    Apr 07, 2008 at 01:40 PM

    If you do not want to set the URL dynamically in your Java code, but need to set up the URL for each server you deploy your software component on, you can also change the URL in Visual Administrator.

    In the Cluster tab, go to: Server->Services->Destinations. Choose your WebService destination, and under Connection Settings, change URL from Default to Custom. You can now set the URL of the web service destination. Afterwards, you will have to restart your proxy application (node "Deploy" in the Visual Administrator tree).

    Add comment
    10|10000 characters needed characters exceeded