cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the Target Address of a Web Service dynamically?

0 Kudos

Hello,

when using a Web Service Model in a Web Dynpro project, you have to define the target address of a Web Service in the Logical Ports Document (which is written to e.g. lports_1.xml).

I have the following problem. If, for any reason, the URL of my Web Service changes (i.e. the hostname or the port), I have to adapt the lports document in all Web Dynpro applications that ure using this Web Service and furthermore I have to rebuild the whole project and I have to redeploy the project.

Is there a way to change this URL dynamically, i.e. means without having to rebuild and redeploy the project?

Thanks in advance,

Christian

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

please follow below steps.

• Add jars

o security.class

o tc/sec/destinations/interface

• Setting WebDynpro project property

o Project>Properties>Web Dynpro References-->Interface references

 Name=tcsecdestinations~interface

o Project>Properties>Web Dynpro References-->Service reference

 Name=webservices

 Name=tcsecdestinations~service

• Setting httpDestination

o Log on to the J2EE Engine as an administrator using the Visual Administrator.

o Expand <SID> -> Server ->Services.

o Select the Destinations service.

o Under Destinations, select HTTP and choose New.

&#61607; HTTP Destination name : DestinationName

&#61607; URL : URL to web service

&#61607; Type : BASIS

&#61607; User : username

&#61607; PASS : Password

o Save

• Dynamically Set httpdestination and Call web service

final InitialContext ctx = new InitialContext();

final DestinationService dstService = (DestinationService)ctx.lookup(DestinationService.JNDI_KEY);

if (dstService== null)

throw new NamingException ("Destination service not available");

final Destination destination = dstService.getDestination("HTTP"," DestinationName");

// getting user name

Properties destprop = destination.getDestinationProperties();

String username = destprop.getProperty("USERNAME");

String password = destprop.getProperty("PASSWORD");

final HTTPDestination httpDestination = (HTTPDestination) destination;

HttpURLConnection httpConnection = httpDestination.getURLConnection();

String httpURL = String.valueOf(httpConnection.getURL());

Request_AdvLocationVer1ViDocument_getLocation obj=wdContext.currentRequest_AdvLocationVer1ViDocument_getLocationElement().modelObject();

obj._setUser(username);

obj._setPassword(password);

obj._setEndPoint(httpURL);

obj.execute();

Former Member
0 Kudos

Hi Christian,

May be you can try following.

You can change the Port URL using Visual Administrator -> Services -> Web Services Security and change in connection settings the URL to Custom and enter new destination value.

Let me know if that helps.

Regards,

Ashish