Skip to Content

In this weblog I will present how to post a message to XI Pipeline ( bypassing Adapter Engine).

For what reasons should I not use Adapter Engine? First of all it’s faster not to use it, secondly to diminish the load on it (if for instance you have interface that must work even if the Adapter Engine is down).

1. We will create a little Web Dynpro just to post the message in NWDS:

File>New>Project>Web Dynpro>Web Dynpro Project.

2. You can ignore the warning message (if you got one).

3. Fill the project name (I called it Post_To_XI) and create the project (click on “Finish” button).

4. We can go to “Applications” and create new application

image

5.Let’s call it Post_To_XI and put it in “sample” package.

6.Create a new component

And finally it should look like this:

image

7. Now we will create GUI just to post the message:

Go to Web Dynpro Components >Post_To_XI>Views–>Post_To_XIView and add 2 textboxes:URL(of XI PipeLine) and Payload(XML we are going to send) and a button, this should look like:

image

image

8. We should create 2 context elements (so we can use the text boxes): Go to Context tab:

image

9. Add 2 variables(URL and Payload):

image

10. Assign these variables to our textboxes: return to layout tab, click your “url” textbox and add value:

image

11. Choose “URL” from the context menu:

image

12. Do the same for Payload TextBox.

13. Now we will add some code to our button –>add an “onAction” event.

Name it “Send” and click the “Finish” button:

image

14. Go to “implementation” tab –>go to “onActionSend” function:

and add the following code:

//@@begin onActionSend(ServerEvent)

//     String SOAPUrl should be in the following format

//Get the url from gui

String SOAPUrl = wdContext.currentContextElement().getURL();

                                   

//Read the payload to post to XI

byte[] b = wdContext.currentContextElement().getPayload().getBytes();

try

{

  //Create the connection to send the message

  URL url = new URL(SOAPUrl);

  URLConnection connection = url.openConnection();

  HttpURLConnection httpConn = (HttpURLConnection)connection;

                                                              

  //Set the appropriate HTTP parameters.

  httpConn.setRequestProperty( “Content-Length”,String.valueOf( b.length ) );

  httpConn.setRequestProperty(“Content-Type”,”text/xml; charset=utf-8″);

  httpConn.setRequestProperty(“SOAPAction”,””);

  httpConn.setRequestMethod(“POST” );

     

  // Everything’s set up; send the XML that was read in b.

  httpConn.setDoOutput(true);

  httpConn.setDoInput(true);

  OutputStream out = httpConn.getOutputStream();

  out.write(b);

  out.close();

    

  //Read the response

  Reader isr = new InputStreamReader(httpConn.getInputStream());

  BufferedReader in = new BufferedReader(isr);

  String inputLine=””;

  String Response = “”;

  while ((inputLine = in.readLine()) != null)

  {

       Response = Response + inputLine + “\n”;

  }

  //Exceptions we write in Payload textbox:

  catch(Exception e)

  {

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

   }

  in.close();

}

//@@end

15. We move to ABAP development:

We will build a function that returns the input:

We go to se80, create new function ZRFC_Return_Input, giving it import variable, called “DATA” and export “DATA_BACK” Variable and write:

DATA_BACK = Data.

in the code section.

16. Make it “Remote-Enabled”.

Finally we move to XI:

In Repository:

17. Create the namespace “XI_Payload_Test”.

18. Name it : “com:test:xi_payload” and save.

19. Make sure that “Import RFC and IDOC Interfaces from SAP Systems permitted” selected:

!https://weblogs.sdn.sap.com/weblogs/images/251698204/import.jpg|height=93|alt=image|width=487|src=https://weblogs.sdn.sap.com/weblogs/images/251698204/import.jpg|border=0!

20. Import our RFC into XI:

image

21. Create Message Interface “RFC_XI_Payload” for Our RFC Message and put our RFC as the interface (it should look like the following):

image

22. Create 2 Message Mapping (1 for request “XI_Payload_Test_MM”):

image

And another one for response “XI_Payload_Test_Response_MM”:

image

23. Create Interface Mapping “XI_Payload_Test_IM” and assign the mapping programs ” XI_Payload_Test_MM” and “XI_Payload_Test_Response_MM”.

24. Activate the “Change List”.

What is left is to build Configuration Scenario: so we move to Configuration:

25. Since we send to XI PipeLine there is no need in “Sender Agreement”.

26. Create Configuration Scenario ” Test_XI_Payload_SC” and save it:

image

image

27. Create Business Service “Text_XI_Payload_BS”:

image

And assign it our interface in sender interfaces:

image

28. Finally we build “Receiver Determination”:

Sender: Service :Test_XI_Payload_BS

          Interface : RFC_XI_Payload

          Namespace: com:test:xi_payload

Configured Receiver : Your R/3 system

Inbound Interface : Interface : ZRFCRETURN_INPUT

                    Namespace: urn:sap-com:document:sap:rfc:functions

Interface Mapping: Name : XI_Payload_Test_IM

                    Namespace : com:test:xi_payload

Receiver agreement : Your R/3 Communication channel.

29. Activate the Change List.

Now we can test our Scenario :

Run WebDynpro, enter the address of the service : I assume that your ABAP Port is 8000. This is true if your System ID is “00”, otherwise you should use another number instead of 8000.

http://hostname:8000/sap/xi/adapter_plain?type=entry&sap-user=xisuper&sap-password=******&namespace=com:test:xi_payload&interface=RFC_XI_Payload&service=Test_XI_Payload_BS

The Payload is :

And Push the “Send” Button

The result is 2 messages in XI:

image

To report this post you need to login first.

3 Comments

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

Leave a Reply