cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically define target address for logical ports (NW'04)

Former Member
0 Kudos

Hello,

when developing a web-service client using standalone proxy, you have to define the target address of a Web Service in the property-page for the Logical Port.

We have the following problem. If, for any reason, the URL of the Web Service changes (i.e. the hostname or the port), we have to rebuild the whole project and then redeploy the project.

Is there a way to change this URL dynamically by java-code?

Thanks in advance,

Jarle

Accepted Solutions (0)

Answers (3)

Answers (3)

sridhar_k2
Active Contributor
0 Kudos

Hi,

You can get Server name Dynamically. You follow the below steps.

1. Create a HTTP Destination in visual administrator which stores the server name and port.

2. Access this variable in your controller init method and build your web service url with server name and port and use _setEndPoint() method

String prefixURL = "http://";

// your Service Address...remove the first part from service url.

String serviceURL = "/TestService/Config1?style=document";

DestinationService dstService = (DestinationService) obj;

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

Properties destprop = destination.getDestinationProperties();

HTTPDestination httpDestination = (HTTPDestination) destination;

String serverName = httpDestination.getUrl();

prefixURL = prefixURL + serverName;

String testURL = prefixURL + serviceURL;

Request<Obj> testReq = new Request<Obj>();

testReq._setEndPoint(testURL);

You need to import below files into your project.

import com.sap.security.core.server.destinations.api.Destination;

import com.sap.security.core.server.destinations.api.DestinationService;

import com.sap.security.core.server.destinations.api.HTTPDestination;

import java.net.HttpURLConnection;

import java.util.Properties

hope it solved your problem.

Regards,

Sridhar

Former Member
0 Kudos

Hi everybody,

I have the same problem. My problem arises by the implementation of the WebAS of the company, which has 2 instances; and the Web Services models of my WebDynpro have a different port according to the instance run.

Really exist a way to change dynamically the logical port of the WebService Model by java-code to solve this problem?

Best Regards.

Simón Arancibia

Former Member
0 Kudos

Hi,

We have the same requirement.

Did you find a solution?

Thanks,

Roelof