Part I of this article, explains how to create a brokered web service in XI 3.0. In this part, I will describe how to consume this web service in a Web Dynpro Application.
Scenario:
- User requests Customer Details via a Web browser
- Data is sent through WebAS to XI using a SOAP adapter
- The message is then synchronously sent to SAP R/3 system via RFC adapter, and a BAPI call is executed to get the Customer details
- The BAPI response is sent to the WebAS to fulfil the user request
In Part I of this article I described how to define web services in XI. In this part, I will focus on using the generated WSDL file to expose the web service using a Web Dynpro application
Prerequisites:
- Good knowledge of XI 3.0 concepts
- Basic knowledge of Web Dynpro Applications
Steps:
- Create a Web Service Model by importing the XI generated WSDL file
- Design a Web Dynpro Application
- Deploy the application on WebAS
Create a Web Service Model
1. Create a new Web Dynpro project in NetWeaver Developer Studio. Expand Web Dynpro node and right click on Models to Create Model
2. Choose to Import Web Service Model and click Next >
3. Specify a model name and a package. Select WSDL source as Local File System or URL since our WSDL file is saved on the local desktop
4. Specify the source of WSDL File and click Next >
5. Click Finish to close the Wizard
Views and Navigation Schema
1. Create a Web Dynpro Component
2. Create two views: StartView and ResultView. You need to embed these views in a window. For this, you can use the context menu for the window created under the component.
3. Create inbound and outbound Fireplugs using the context menu for both the embedded vievs.
4. Specify the navigation schema using the Create a navigation link button on the left hand side toolbar as shown below:
Add the Web Service Model
1. Open the component by double-clicking on it
2. In the Used Models area, right-click and choose Add Existing Model. Select the Web Service model imported previously.
3. The model now appears in the Used Models area.
Define Model Binding
1. Right click on Component Controller and choose Apply Template
2. Select the Service Controller and click Next >
3. Select the Model class for the Model Binding and click Next >
4. Select the Context Elements you want to bind and click Next >
5. Accept the proposed method name and click Finish to generate the method
Define Context Mapping
1. Open the component by double-clicking on it. In the left hand side toolbar, choose Create a data link. Join the StartView and Component Controller. Drag reqCustomerNoMT folder from right hand side to the left hand side. Another wizard window appears.
2. Select the fields for context mapping. Click OK and then click Finish.
3. Similarly join ResultView and Component Controller using fields from Response folder
User Interface Design
Create the necessary User Interface elements for both the Request and Response Messages and the Action Methods. An example is shown below:
Note:
XI does not accept unauthenticated requests. Hence, you have to pass the logon credentials along with the request. For this add following lines of code in the executeRequest_CDWS_MI_CDWS_MI( ) method implementation of the Component Controller:
wdContext.currentRequest_CDWS_MI_CDWS_MIElement().modelObject()
._setUser(“username");
wdContext.currentRequest_CDWS_MI_CDWS_MIElement().modelObject()
._setPassword(“password");
Create and Run the Application
Finally, create an application for the component, build the project and deploy the application on WebAS. Sample execution of the application is shown in the figure below:
There are various ways of consuming the web services created via XI. I have just described one of the ways. In the scenario discussed here, XI acts as an intermediary (as a broker) between the Web Application and SAP R/3. Such web services are called as Brokered Web Services.
Hi,
Good article!
Is it possible to achieve this using Web Dynpro for ABAP?
Thanks,
Vin
Hi Vin,
It is very much possible to achieve this using Web Dynpro for ABAP, although the procedure will differ slightly. As I stated in Part I of this article series, XI only generates WSDL file. We can consume the web service in any type of web application. Any tool (say Web Dynpro, Microsoft .NET, Web Dynpro for ABAP) that supports importing web service definitions (WSDLs) to create web applications can be used to consume and make the web service available.
Regards,
Riyaz
Very helpful article.
Thanks,
Vivek
Very Good Article…very helpful
Nice article. I found it because I was looking for how to set the username and password for a web service requiring authorization. I saw the part about _setUser and _setPassword, but in my DeveloperStudio the wdContext…..modelObject() doesn’t have a _setUser or _setPassword method, only _setAttribute(QName, Object) and _setField(QName, Object). Have I done something wrong?
Nice Article. I found it because I was trying to find out how to send username and password to a web service requiring authorization. Problem is, the modelObject() returned to me from wdContext..etc.. doesn’t have _setUser and _setPassword methods, only _setAttribute and _setField. Have I done something wrong? Using NetWeaver 2004s.
The web service isn’t an XI service, but that shouldn’t affect my client code.
I believe there are better means of passing credentials for authentication. In this article I have hard-coded the username and password. But in real-time, you may want to validate them against a database…may be in the similar way as SSO authentication does in EP. I dont have much idea as to how this could be achieved, you may want to consult an EP consultant who would be able to assist you better.
Hi Riyaz,
Its nice article. You articles are giving more confedence to the beginers. Nice going. Thanking you a lot..
Hi
you said you can do the same thing using ABAP webdynpro. can you give me the steps for that. I could not find how to import the WSDL file in case of ABAP webdynpro.
thanks
sankar
Hi Sankar,
Check out this blog article by Thomas Jung. See the Release 640 section, the later half of the article where he has explained the step-by-step procedure of consuming SOAP based web services in Web Dynpro ABAP.
Hope this helps.
Regards,
Riyaz
Thank you very much Riyaz
Hi
In the SDn blog you have referenced ( https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1012 ) the author uses a public webservice, but when we create a webservice in XI we will have different format of the url like below
http://:/XISOAPAdapter/MessageServlet? channel=::
Can we use this url stright away or do we need to change anything??
thanks
sankar
Hi Sankar,
You can save the WSDL created in ID on your local machine. Then choose Local File option when you are prompted to specify WSDL source. Alternatively, you also have option of using XI repository as WSDL source.
Regards,
Riyaz
Hi
I have genrated a WSDL file from webservice to RFC scenario in XI
I am trying to use thislocal wsdl file as you suugested in creating a client proxy in SE80 transaction. But when we create the logical port LSCONFIG transaction we need to enter some parameters in “call parameters” tab.
In case of URL we can enter URL where the WSDL file is located, but in our case where we are using the local WSDL file what we need to enter.
thanks
sankar
Hi,
I given local system path for wsdl file, But I am getting following error.
FileNotFoundException.
Regards,
Prasad.
Hi Riaz,
We have to give the authentication (user ID and password) to the client who consume the webservice. But we cant assign the ID all the roles. Can you please tell me, what the exact roles we should assign for such ID ?
Regards,
Subhendu
Hi,
To know about the authorizations and roles to be asigned to any id, check the link below.
http://www.erpgenie.com/sap/netweaver/xi/xiauthorizations.htm
Regards,
Phani
Hi Ryaz,
I have the NWDS installed on my local computer, but I can´t use it.
There are no kind of project type, none libraries, it seem that the NWDS is empty, “Blank”.
Where Can i find something saying more about the NWDS, how to install ? What Do I miss to my NWDS works ? Do you have some articles to tell me ?
Thanks a ton for your help!
Diego Crespo
Have you installed the correct version of JDK that corresponds to your NWDS version? If not please install the right JDK/JRE and then reinstall NWDS. In my opinion, only correct version of JDK is the prerequisite for NWDS.
Also, in order to be able to deploy your application, you need to add the hostname/port of your SAP WAS to NWDS config options.
Hi Riyaz,
I wish to consume a third party web service using NWDS 7.1. How can I do that?
Also I want to test the same in WS Navigator. How can I do the same?
Thanks.
Rajat
Hi Riyaz,
When I am triggerring the message from Webservice I am getting a 401 Unauthorized error. I am using sender SOAP channel in SAP PI. The same works good when I change the URL to the other environments.
Could you suggest.
Thank you ,
Hemanthika
Hi Rajat,
I guess the process would be simlar to the one explained in this article. You can import the WSDL in NWDS 7.1 and bulid your application around it. Web services deployed on SAP Web AS can be tested using WS navigator.
Hi Riyaz,
I am trying to Integrate SIEBEL and SAP using SAP PI, could you please provide a example to do the same
Thanks in Advance
Regards
Mohan
You could create a WSDL and provide it to Siebel team who can consume it in their application.
Hello.
I have a problem, I have a requierement to expose a PI wsdl via portal so that portal can act as a interemediary. they want clients to consume this service trought the portal so IP of PI wont be comprised. Any toughts how can I achieve this ?