Sunteți pe pagina 1din 17

Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 1 of 17

Products Industries Support Training Community Developer Partner

Home / Community

Implementing Sender Receiver Java proxy sce


PO/PI
January 28, 2014 | 5,665 Views |

Vikas Singh
more by this author

SAP Cloud Platform Integration for process services

share share tweet share

Follow RSS

I have been doing some work of late with Java proxies on SAP PO .I tried to use product
documentation to understand their working. Product documentation is always the best source of
information but things are much clearer for me after I’ve already developed something using a
concrete example.

I hope that this post will be useful for anyone trying out SAP PI Java proxies. Here both the sender
as well as receiver are Java proxies and it has been implemented on a 7.31 SAP PO system.

Scenario: We’ll use the flight demo model scenario with two Java proxies – interfaces
FlightSeatAvailabilityQuery_Out_new for outbound service call and
FlightSeatAvailabilityQuery_In_new for inbound service implementation.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 2 of 17

Broadly, we’ll have three major objects:

Sender Proxy ( Consumer ) – Being sender, this proxy doesn’t provide any service but is used to
make the outbound service call.

Receiver Proxy – It has the actual service implementation .

Servlet ( for testing ) – As the proxy calls are to be in an JEE environment, we’ll create a simple
Servlet for testing.

At a high level, the below diagram shows what we’ll end up creating. We’ll need to create a
configuration scenario as well but that shouldn’t cause too much grief.

We need to create the below projects in NWDS. The names in italics are our project names.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 3 of 17

a) Dynamic Web Project ( JavaProxyWeb ). This will hold consumer proxy (sender objects) and
servlet used for testing.

b) EJB Project ( JavaProxy ) : This will hold service implementation on the receiver side.

c) EAR (JavaProxyEAR) – EAR to deploy JEE objects.

So we have the below three projects to start our work..

Consumer Proxy Generation

Let’s generate code on the sending side ( consumer proxy ) . We don’t want to chose a Javabean
as there is no actual service implementation. We’re just generating client to call our proxy and
hence chose “Generate Client”.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 4 of 17

In the next screen , check the values of Server/ WebService runtime and verify your Dynamic Web
Project and EAR project are chosen.

And we don’t have to WSDL as we’re not really using the end-points for any service all . We’ll be
creating a configuration scenario in PI Designer to generate the configuration.

After that, let the wizard go through default values and just press finish.

Inbound Service Generation

For our inbound service implementation, let’s take the corresponding service interface. This time
we want to generate a bean and hence chose “Generate JavaBean Skeleton”.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 5 of 17

And as we’re not really going to use any client, we can move the slider for client to minimum and
just generate the shell for the Web Service.

Our EJB project looks something like this.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 6 of 17

And the web project should look similar to this.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 7 of 17

Adding Servlet to web project ( for testing )

As we need a servlet for testing, let’s create one in our web project.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 8 of 17

Additions to servlet which makes the outbound proxy call object

Add the WebService annotation with the service name and create an instance of the Service.

This is the outbound service call. We need to create an instance of port and as we’re using XI as
the message protocol, we need to use methods from XIManagementInterface.

and the actual proxy call to get the result.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 9 of 17

We have set the business system programmatically. It’s also possible to not set it here and
instead set Party and Sender Service in configuration for Java proxies ( this appears once the
project is deployed ) in Port Configuration.

Inbound Service Implementation

For the inbound service implementation, we’ll need to add @XIEnabled annotation and it’ll need
@TransportBindingRT as well. Add @XIEnabled and IDE will help with @TransportBindingRT as
they’re required together.

Project Deployment

Our EAR has our EJB as well as dynamic web project.Deploy the EAR .

Service verification in NWA

Once the project is successfully deployed, we should be able to find our consumer proxy . This
was actually confusing for me. I tried to deploy the generated client without the actual service call
in servlet and it never worked for me. Only when I created the servlet making the outbound call I
could see the outbound proxy. It’s best to finish outbound proxy and inbound service
implementation along with consumer application ( servlet in this case ) and then try to deploy them
in one shot.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 10 of 17

Below is the screenshot of the port configuration . We can set the party/ business system here if
it’s not set programmatically.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 11 of 17

Similarly, the inbound service shows up as well in Service Definitions.

Our development is done. Now, we need to create an integration flow with the required sender /
receiver interface values.

Sender communication channel uses XI message protocol for a SOAP adapter and HTTP as the
transport protocol.

Similarly, create a receiver communication channel of type SOAP, using HTTP as transport
protocol and XI as message protocol.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 12 of 17

Path prefix for sending proxy messages bia JPR is /MessagingSystem/receive/JPR/XI.

Do a test with the URL going to be used on the receiving side to verify it’s running.

Now, configure the receiver communication channel. Change the authentication mode to “Use
logon data to no-SAP system’ and provide

authentication credentials.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 13 of 17

Activate the iFLow and we’re ready to test the set up.

Testing

Fire the servlet and it should come up with the below screen

Put your flight and connection details. We aren’t really using the date and hence it’s not in screen.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 14 of 17

And if everything goes well, we should get the below screen.

Voila ! Our proxy worked and it has come back with the response.

This matches with our service implementation – we’re just returning 20 free and 200 max business
class seats .

The message can be displayed in RWB / PIMON.

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 15 of 17

The audit log confirms that JPR has successfully delivered the message along with the response
message.

The source code is available on https://github.com/viksingh/PIJavaProxy . I’ve just put the


outbound proxy call in the servlet and the inbound service implementation as these are the two
files we need to modify. Rest all were left standard including deployment descriptors.

Alert Moderator

7 Comments
You must be Logged on to comment or reply to a post.

Former Member February 11, 2014 at 8:02 pm

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 16 of 17

Hi Vikas,
This is a great post. I think it will be very useful. Thanks for sharing your knowledge.
Ryan

Harish Mistri February 11, 2014 at 8:11 pm

Thanks Vikas for sharing the infromation. It is simple and complete.

Former Member March 10, 2014 at 10:07 am

Very well ExplainedMMMMMMMM.


Regards
E.Ravi chandra reddy

Former Member May 22, 2014 at 9:23 am

Great job!

Former Member July 25, 2014 at 3:43 pm

Hi Vikas,
Your topic seems interesting Can you please update the crashed images pleaseM
Regards,
Avinash
Vikas Singh Post authorNovember 24, 2014 at 5:01 am

Which images have crashed / you’re unable to see ?


Former Member November 26, 2014 at 12:11 pm

Hi Vikas,
Now the images are visible previously they were not visible. thanks for the response.
Regards,
Avinash

Share & Follow

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018
Implementing Sender Receiver Java proxy scenario in SAP PO/PI | SAP Blogs Page 17 of 17

Privacy
Terms of Use
Legal Disclosure
Copyright
Trademark
Sitemap
Newsletter

https://blogs.sap.com/2014/01/28/implementing-java-proxy-scenario-on-sap-po/ 9/5/2018

S-ar putea să vă placă și