cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a web services model?

Former Member
0 Kudos

hi all

I would like to know how I can run a web service model...

I have everything set up, the only thing I need is to run it and display it on the webdynpro...

model: ConsumeWS

webservices: GetDataEmployee

I hope I can help, thank you very much

Accepted Solutions (1)

Accepted Solutions (1)

former_member201361
Active Contributor
0 Kudos

Hi Pablo,

u have import the web services , right click on model --> import .

add the model as the used model for the component .

create a data link between component controller and model and do the mapping.

in the component controller , instantiate the model classes and execute the model.

please refer this link :

[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10c2c440-7f8c-2b10-7db0-dce34360f118]

Thanks and regards

Fazal

Answers (12)

Answers (12)

Former Member
0 Kudos

hi

can u tell the problem in more details...

if you are setting some values from form to Webservice...

you can store that form values first in to local context then you can set this value to webservice...

Former Member
0 Kudos

How do you assign the value of entry?

if the code is next:


 public void wdDoInit()
{...
WSConnect model = new WSConnect();
wdContext.nodeRequest_EmployeeQuery_R().bind(new Request_EmployeeQuery_R(model));
...}

public void executeRequest_EmployeeQuery_R( )
{...
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try
{
 wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();
 wdContext.nodeResponse().invalidate();
 wdContext.nodeEmployeeQuery_RResponse().invalidate();
 wdContext.nodeResponse2().invalidate();
 wdContext.nodePersonal_Data().invalidate();
 wdContext.nodePersonal_Data_R().invalidate();
}catch(Exception e){
 manager.reportException(e.getMessage(), false);
}....

because when I generate a form to enter data, this is blocked and can not write

Former Member
0 Kudos

I need to import that library use "Stub"?

ctrlshitfO Import libraries

thanks Siva

Edited by: Pablo Umaña on Jan 21, 2009 7:24 PM

Edited by: Pablo Umaña on Jan 21, 2009 7:26 PM

Former Member
0 Kudos

hi,

problem may be you are first setting the values than binding to context...

but first you have to bind to node ...

then set the value...

try this change may be it work ..i am not sure...

Former Member
0 Kudos

thank you very much for your answers, but now I receive the following error:

Exception on execution of web service with WSDL URL

'http://chcvd02501:50000/GetEmployeeData/Config1?wsdl'

with operation 'EmployeeQuery_R' in interface

'

GetEmployeeDataVi_Document'

and this is the code that includes


WSConnect con = new WSConnect();
		
Request_EmployeeQuery_R req = new Request_EmployeeQuery_R(con);
EmployeeQuery_R query = new EmployeeQuery_R(con);
		
req.setEmployeeQuery_R(query);
wdContext.nodeRequest_EmployeeQuery_R().bind(req);
try{
  wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();
  wdContext.nodeEmployee_R().invalidate();
}catch(Exception e){
  wdContext.currentContextElement().setError(e.getMessage());
}

What could it be?

it is necessary to make any changes to the engine? I have configured the SLD?

because the only thing I did was to deploy the project

Thanks!

Edited by: Pablo Umaña on Jan 20, 2009 8:17 PM

former_member197348
Active Contributor
0 Kudos

Hi Pablo,

Change your code to

try{

wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();

wdContext.nodeEmployee_R().invalidate();

}catch(Exception e){

wdContext.currentContextElement().setError(e.getMessage());

}

to

// If you are using *Web Service Model*
try{
wdContext.currentRequest_EmployeeQuery_RElement().modelObject()._setUser("username");
wdContext.currentRequest_EmployeeQuery_RElement().modelObject()._setPassword("password");
  wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();
  wdContext.nodeEmployee_R().invalidate();
}catch(Exception e){
  wdContext.currentContextElement().setError(e.getMessage());
}

no imports are required for this.

or

// If you are  using *Adaptive Web Service Model*
try{
wdContext.currentRequest_EmployeeQuery_RElement().modelObject().setInvokerProperty(Stub.USERNAME_PROPERTY,  "username");
;
wdContext.currentRequest_EmployeeQuery_RElement().modelObject().setInvokerProperty(Stub.PASSWORD_PROPERTY, "password");
  wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();
  wdContext.nodeEmployee_R().invalidate();
}catch(Exception e){
  wdContext.currentContextElement().setError(e.getMessage());
}

Organize imports ( CtrlShiftO) after adding this code. or import javax.xml.rpc.Stub;

Regards,

Siva

Edited by: Siva Rama Krushna on Jan 21, 2009 10:01 PM

Former Member
0 Kudos

Hi Pablo,

There can be two possibilities for the following error.

1)Configuration of the destination in Visual Admin should be correct.

2)Setting up all the input parameters correctly

WSConnect con = new WSConnect();
		
Request_EmployeeQuery_R req = new Request_EmployeeQuery_R(con);
EmployeeQuery_R query = new EmployeeQuery_R(con);
		
req.setEmployeeQuery_R(query);
wdContext.nodeRequest_EmployeeQuery_R().bind(req);
try{
  wdContext.currentRequest_EmployeeQuery_RElement().modelObject().execute();
  wdContext.nodeEmployee_R().invalidate();
}catch(Exception e){
  wdContext.currentContextElement().setError(e.getMessage());
}

In the above code EmployeeQuery_R would be the node which would contain some input parametrs , you need to set all input parameters, then only Webservice model will be executed.

Before Exectuion of model instance set all input parameters.

eg.if you EmployeeID and name as input parameters you need to add following code

EmployeeQuery_R.setEmployeeID(1);
EmployeeQuery_R.setEmployeeName("Name");

Or else send your node structure.

Regards Shruti.

Former Member
0 Kudos

for exceuting the webservice following is the line of code...

the name of request node is Request_MiARG_Req_miARG_ReqElement

1. bind the webservice to node .....code is....

wdContext.nodeRequest_MiARG_Req_miARG_Req().bind(new Request_MiARG_Req_miARG_Req());

2. set the input values code is...

wdContext.currentRequest_MiARG_Req_miARG_ReqElement().setPROJECTID(wdContext.currentVn_ProjectIdElement().getVa_ProjectId());

3.Exeute the webservice code is...

wdContext.currentRequest_MiARG_Req_miARG_ReqElement().modelObject().execute();

Former Member
0 Kudos
Former Member
0 Kudos

thank you for your responses...

but I can't run the model, which are not lines of code that I put to run the model.

put the following lines of code:


WSConnect con = new WSConnect();
EmployeeQuery_R employeeQuery = new EmployeeQuery_R(con);
EmployeeQuery_RResponse employeeQuery_RResponse = new EmployeeQuery_RResponse(con);

What else should I put to run the model?

thanks!

Former Member
0 Kudos

Hi Pablo,

You need to create webservice destinations in Visual Administration as explained in following link

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b2bc0932-0d01-0010-6d8e-cff...

Then you need to write the following code to execute the model.

WSConnect con = new WSConnect();
EmployeeQuery_R employeeQuery = new EmployeeQuery_R(con);
Here you need to set input parameters using request node object.

E.g.If your node structure is as follows.

Request Node

-EmpName

-EmpId

then you need to set these values.

employeeQuery.setEmpName("Name");
employeeQuery.setEmpId(1);

After seeting all the parameters you need to execute the model using same request Object.

try
   {employeeQuery.execute;} 
    catch(Exception e)
    {
      manager.reportException(e.getMessage(), false);
    }

After Execution you can display data in webdynpro screen from response model node.

EmployeeQuery_RResponse employeeQuery_RResponse = new EmployeeQuery_RResponse(con);

For Successful execution of Model following points need to be consider.

1) Correrct setting of input parameters

2) Creation of Web service destination in Visul Administrator with proper user ID and password

Regards Shruti.

Former Member
0 Kudos

Following are the steps while runing webservice..

1. create project.

2. create a webservice model and import your model.

3. open data modeler and map model to component controller.

4. Mapped only request node value..

5.then open component controoler implemenation..

bind the node to model...

give input values...

and execute webservice....

if u need code please reply ii will also provide that..

Former Member
0 Kudos

Hi Pablo ,

1. Create a new project and in turn a new application under the project in webdynpro.

2. Create new component and windows and views(as per your requirement like GetEmployee) embeded to the window under the application.

3. Under application there will be something called model , right click on it create a model -> select deprecated web service -> give the name and url of the web serivice if its available as url and configure proxy .

4. Bind the model to component and in turn the component to the view by using the data link.

5.Deploy and run the application , you can run your web service.

Also you can create adaptive web service when you try to create a model , on right clicking model and clicking next,

Using adaptive web service model , check the below link

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b2bc0932-0d01-0010-6d8e-cff1b2f2...

Regards,

Sam Charles J

Former Member
0 Kudos

Hi Pablo,

Check the following blogs:

/people/bertram.ganz/blog/2007/05/25/new-web-dynpro-java-learning-material--using-adaptive-web-service-models

/people/community.user/blog/2007/12/18/consume-services-with-java-web-dynpros

These will guide you.

Regards.

Rajat

Former Member
0 Kudos

hi,

To add webservice to webdynpro you should create a model and link it to the component controller.

use the following links,

this describes how to add ur own webservice (using local file system)

http://www.riyaz.net/blog/xipi-consuming-xi-web-services-using-web-dynpro-part-ii/

also check out (using uddi)

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/98347a90-0201-0010-d1a6-cc4d8091...

Regards

Jayapriya