cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service - Access through Web Dynpro

Former Member
0 Kudos

Hi all,

I have created a Web Service (java) and made it available in a server. The web dynpro applications make use of it by importing web service using wsdl file's url. In case, I want to move the web service to another server, then the web service model of the webdynpro applications has to be deleted and recreated. How can I avoid modifying applications' model and move the web service to another server? (Or) is there any possible solution to handle this problem?

Srinivasan T

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi srinivasan,

Although it is not possible to directly re-impost web service model in to the dev studio but there is a wrok around to do the same. Refer to the following link for an article on the same,

/people/bertram.ganz/blog/2005/10/10/how-to-reimport-web-service-models-in-web-dynpro-for-java

Regards,

Guru

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Srini,

You can use AdpativeWebservice Moldel which supports this.

Refer to

Regards, Anilkumar

Former Member
0 Kudos

Hi Srinivasan,

If this is the case, then use the HTTP destination for this.

What you need to do is:

1. Create one HTTP destination in visual administrator at services-> Destinations. Provide HTTP url of the your web service and the security options.

2. Specify this HTTP destination in the code before executing web service model.

Write following code for that:

wdContext.current<node name>Element().modelobject()._setHTTPDestination(<Specify HTTP destination name>);

Then execute your web service model.

Now, whenever you want to change the server on which your web service is running, make change in the HTTP Destination in visual administrator.

Regards,

Bhavik

Former Member
0 Kudos

Hi,

I created HTTP Destination in the VA and referred to Webservice available in a remote server.

But, in the coding, after ...........modelobject()._, I am not getting the _setHTTPDestination().

Any suggestions?

Saravanan

Former Member
0 Kudos

Bhavik,

I tried your solution and created a HTTP destination and used that in my code. But if I change the URL in the HTTP destination my web service model still points to the old web service url. Its as though the following line doesn't have any meaning.

modelObject._setHTTPDestinationName("MyService");

Can you please tell if there are any other settings to be done to really make use of HTTP destination for dynamically changing which web service I am pointing to?

Thanks,

Kiran

Former Member
0 Kudos

Hi Saravanan,

This is Version problem. This method only avliable in 2.0.15. So installed service pack 15.

Kind Regards,

S.Saravanan.

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

From Webdynpro you can access the same web service from different server without re generating the model.

Go to controller for project modify with following same code:

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;

public void wdDoInit()

{

//@@begin wdDoInit()

InitialContext ctx ;

Object obj;

DestinationService dstService;

Destination destination;

HTTPDestination httpDestination ;

HttpURLConnection httpurlconnection = null;

Properties destprop = null;

String serverName = "";

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

String prefixURL = "http://";

try

{

ctx = new InitialContext();

obj = ctx.lookup(DestinationService.JNDI_KEY);

dstService = (DestinationService) obj;

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

destprop = destination.getDestinationProperties();

httpDestination = (HTTPDestination) destination;

serverName = httpDestination.getUrl();

prefixURL = prefixURL + serverName;

}

catch(Exception ex)

{

manager.reportException(ex.getMessage(), false);

}

serviceURL = prefixURL + serviceURL;

//$$begin Service Controller(-1594161185)

Request_ServiceViDocument_add Request= new Request_ServiceViDocument_add();

Request._setEndPoint(serviceURL );

wdContext.nodeRequestupdateCmonitor().bind(Request);

}

Do this step also:

(1) In the Package explorer, select your project, right click, cick on "Set Additional Libraries.."

(2) Select security.class and tc/sec/destinations/interface

(3) Click on menu Project > Properties, goto Webdynpro refereces node in the tree and add the following

(a) Interface References: tcsecdestinations~interface

(b) Service References: tcsecdestinations~service

Hope this will solve your problem

Regards

Suresh

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

small change put this line during binding(request) on above code.

wdContext.nodeRequestadd().bind(Request);

Regards

Suresh

Former Member
0 Kudos

Suresh,

I'd just like to say thanks for your solution.

My problem has been this:

I have developed a Web Dynpro application which uses Java persistence to the J2EE server's database, via a web-services call to an EJB (which seems to be SAP's recommended approach). The web service is always on the same host as the Web Dynpro, but we have different instance numbers for Dev, test & Production so the port number keeps changing. This gave us a problem with transporting the Web Dynpro EAR file, but your solution means that the EAR file no longer contains a hard-coded WSDL URL.

It would be nice if SAP added the option of setting a names HTTP destination when creating a Web Service model - until they do, your solution works a treat.

Thanks again,

Darren

Former Member
0 Kudos

Hi all,

I have got a similar problem like Siva.

I have already created a http-destination in visual admin, but I can't find the _setHttpDestination-method according to the modelObject.

I am using NW04 SP17.

Does anybody know how to solve this problem?

Thank you in advance.

Kind regards, Patrick.