cancel
Showing results for 
Search instead for 
Did you mean: 

How to create Web Service based on PI WSDL message

Former Member
0 Kudos

Hi all,

we have following scenario:

Within PI (version 7.1) we set up a message type and inbound service interface. This service interface should send the PI message to a web service running on a SAP J2EE (version 7.01). As the PI message is sent as WSDL I thought it should be easy to build a web service on the SAP J2EE based on this WSDL from PI.

Unfortunately, I have problems creating the Web Service.

For my current project we integrated the NWDI to the SAP NetWeaver Developer Studio and I'm required to add the Web Service to an existing DC (Development Component) within the NWDI.

What I tried so far is:

- I created a Deployable Proxy Project and within this I created a Client Proxy Definition based on the WSDL from the PI. But I can't add this Proxy to the DCs of the NWDI and I don't know how to implement my own coding here in order execute specific functions.

- I created a new class within the NWDI DC and a public method. Based on this I created a Virtual Interface and a Web Service Definition (WSD). Then I added this to a Web Service Deployment Descriptor. I uploaded this to the SAP J2EE. But I'm not able to access this and I don't know hoe to assign the WSDL here.

I also tried here to create a client proxy based on this WSD as I thought I might assign the WSDL here. But I don't see the WSD in the list of Web Services uploaded to the SAP J2EE...

Can you please advice me how to create a Web Service in such an environment?

regards

René Jurmann

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Tahir,

sorry that you needed to wait this long - but this is how I created the web service:

The steps on how to create the web service in NetWeaver Developer studio are nearly the same as described in the blog http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5838. [original link is broken] [original link is broken] [original link is broken]

Some steps I just skipped and some others I added. Some of the steps I did the way I described it as I needed to connect the web service with the SAP PI.

Prerequisites:

Add Java Perspective and J2EE Development Perspective to the open perspectives.

Within "Window - Preferences - Web Services" check "Soap extensions visible in the virtual interface editor"

The SDM of the corresponding SAP J2EE is configured within "Window - Preferences"

Create a Development Component (DC) with type "J2EE -> EJB Module"

The business logic of the web service will be implemented in an Enterprise Java Bean (EJB). So first the EJB component must be created:

Choose "File -> New -> Other"

In opening PopUp choose "Development Component -> Development Component Project"

Select the Software Component for which you want to add the DC (e.g. "Local Development -> MyComponents")

Choose now vendor, name and type:

vendor is an alpha-numeric string of 20 characters starting with a letter - all in lower case

name is an alpha-numeric string starting with a letter - all in lower case

vendor and name concatenated must not be longer then 40 characters

the name can be separated into different part using "/" as separator

each part of the name must not be longer than 8 characters

the type is "J2EE - EJB Module"

you can specify a Caption as general description for the web service

Create new EJB

To create the EJB itself:

In J2EE DC Explorer of J2EE Development Perspective expand new DC and right-click on folder "ejbModule"

Choose "New - EJB" with following details:

EJB Name: <name as for PI service Interface to be created - starting in upper case>

EJB Project: <pre selected>

Bean Type: Stateless Session Bean

Default EJB Package: <corresponds to namespace in PI>

generate default interfaces: Checked

Regarding the "Default EJB Package" this should be created according the namespace in PI for which all PI objects will be created. This only applies if you have some naming conventions here.

Example:

Namespace in PI is: http://company.net/pi/SOFTWARE_COMP/Application

The corresponding package then is: net.company.pi.software_comp.application

Implement coding for web service

As the web service will be called via PI some transfer variables will be submitted. Most likely, those variables will not be standard type (e.g. String) but a complex type. Those types must be generated as Java classes. Below an example of a complex type I needed:

Data Type

net.company.pi.software_comp.application.types.MessageProcessingInformation

Structure:

Element name Element type

sendingSystemID String

interfaceID String

businessProcessVariantCode String

testIndicator Boolean

For every element described a public "get", "set" and "has" method must be created in the corresponding Java class:

package net.company.pi.software_comp.application.types;

import java.io.Serializable;

public class MessageProcessingInformation implements Serializable {

protected String sendingSystemID;

protected String interfaceID;

protected String businessProcessVariantCode;

protected Boolean testIndicator;

public String getSendingSystemID() {

return sendingSystemID;

}

public void setSendingSystemID(String value) {

this.sendingSystemID = value;

}

public boolean hasSendingSystemID() {

if(sendingSystemID != null && !sendingSystemID.equals("")){

return true;

}

return false;

}

.

.

.

}

All Java classes representing complex types and all classes referenced here (used for sub-types) must implement java.io.Serializable. Java standard types which do not implement this class must not be used as sub-types.

As soon as all data types are declared the real business logic can be implemented:

In J2EE DC Explorer of J2EE Development Perspective expand DC - "ejb-jar.xml" - <Name> and double click on "ejbCreate"

In detail view select folder "Business Methods" and click "Add"

choose name of business method - this should be the same as the PI message type used for the service interface - starting lower case

return type should be "void"

add needed parameters fully qualified - including package (as specified in PI and created previously in DC)

you can mark certain parameters as array if necessary

Remark:

It might be that after saving you get an error. This might be as the package name of one component is copied to the corresponding Java class at the very beginning (before the package declaration within the Java class). Simply delete the string here.

It also might be, that the new business method is only defined in the remote interface class but not in the bean class. Just create an according method in the bean class.

Within the newly created business method within the bean class you can now implement the business logic.

Create a DC with type "J2EE -> Enterprise Application"

In order to create the "real" web service and deploy it to the J2EE an Enterprise Application project has to be created. So create a new DC as for the EJB Module but choose as type "J2EE -> Enterprise Application".

After the DC is created right click on the EJB DC and choose "Add to EAR Project". Choose the new DC.

Create web service for EJB

As soon as you implemented the business logic you can create the "real" web service. Therefore:

Right click on the EJB name below "ejb-jar.xml"

Choose "New - Web Service"

Choose proper "Web Service Name" and "Configuration Name" (probably oriented at the EJB name)

Copy the URL of the web service - you'll need it later for PI configuration

on the second next screen use the same name for "Virtual Interface" and "Web Service Definition" (the name should be the name of the "Endpoint")

the "EAR Project" should be preselected

Unfortunately, the web service can't be used in its current configuration to be accessed by PI. Therefore the Virtual Interface must be changed. To do so, expand folder "Virtual Interfaces" and double click the virtual interface created.

Within the detail view expand in tabs "Mapping" and "Types" the complete folder structure. For any "SOAP Extension" where a namespace can be defined use as namespace the corresponding namespace in PI (e.g. http://corpintra.net/pi/CBFC_GLOBAL_SAP_APPL/BillerDirect) but do not change any "Soap Extension" of a standard Java type. (if you don't have any naming convetions for namespaces in PI you can leave the SOAP Extension here. But then the namespace in PI should be set accordingly.)

Probably it can be necessary on top level "Soap Extensions" in tab "Mapping" to leave "Use Namespaces for Parameters" unchecked. For some of my web services this parameter must be checked for others not - just try.

If you can define a "New Name", "Local Name" or "Item Label" for a Soap Extension then use a name with starting upper case letter. (For Java Naming conventions most of the data type names will start with lower case letters.) Especially the method name must be renamed this way in order to stick to the PI namings.

As a last point to change here check in tab "Mapping" all "Incoming Parameters" which you specified as array. Use for those as "New Name" a different name - do not just simply change from lower case to upper case. This is necessary as on PI we need to create two levels although here only one is specified.

For any own sub-type declared as array the name within the coding should also differ from the corresponding Java Class name the type refers to.

If all this is done you can deploy the web service to the J2EE:

right click on "Enterprise Application" DC and choose "Development Component - Build..." and build all corresponding components

right click on "Enterprise Application" DC and choose "Development Component - Deploy"

Test the new web service via <J2EE URL>/wsnavigator/enterwsdl.html

Create PI interface

After the web service is created successfully the PI integration can be started.

Therefore, within the Enterprise Services Builder create a data type according to the web service definition. All components defined on top-level for this data type should be declared as incoming parameter for the web service business method. Therefore it could be necessary to create some sub data types on PI first and add those to the "master" data type.

Ensure that the names of the components correspond to the names defined in the web service (see virtual interface here). Those names must exactly be the same - including lower/upper case. Also take care for the ordering of the components.

In case you need to include arrays following applies:

The upper level is of occurrence "1:1". This has only one sub-entry with occurrence "1:n". The names for upper and sub-level must not equal.

Based on the data type a message type is created. The name of the message type must be exactly the same as the name of the web service business method. (Hint: the name of the web service business method was most likely changed in the virtual interface. Then this name must correspond to the message type name.) Based on the message type an asynchronous inbound interface is to be created (which will be referred in the Integration Directory). The operation name for this interface (left panel) should be the same as the name for the web service business method.

Create PI mappings and routings

How to map (message mapping and operation mapping) from source to the web service message I wont explain here as this depends on the source message. The only important things here are:

When creating the SOAP communication channel within the Integration Builder the "Target URL" is:

<J2EE URL>/<Access URL as specified in web service creation>?wsdl&style=document

The soap action is the name of the web service business method.

Most likely the web service needs authentication to be executed.

Former Member
0 Kudos

Fixed it by myself after lot of trying.

Who is interested in the solution just ask.

Former Member
0 Kudos

Hi Rene ,

Please tell me how did you to create WebService

Regards

Tahir

Former Member
0 Kudos

Hi,

my question is still open.

I find lot of examples how to create a web service based on SAP J2EE 7.1 but no real good example for SAP J2EE 7.01 with my mentioned criterias.

Can noone help me?

VijayKonam
Active Contributor
0 Kudos

If you want implement a Java client proxy(WS Consumer), you would need an outbound interface in PI. An inbound interface is used for creating Java Server Proxy (WS Provider).

Based on your requirement you can generate the WSDL from ESR by right clicking on the appropriate interface and generate the Java Proxy Classes. Add these to your development package (Not exactly sure how you would do that.. I knew just the theory part of it..!!) and implement or call.

VJ