cancel
Showing results for 
Search instead for 
Did you mean: 

Java mapping to Edit Payload - Sender HTTP

0 Kudos

Dear Experts

I have a sender HTTP scenario - thirdy party(HTTP)- PI- ECC

The payload sent by sender does not confirm to PI standards and hence message mapping fails, below is payload

User=abc&password=def&TP_XML=<?xml version="1.0" encoding="UTF-8"? Standalone="no">

<!Doctype Win_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd">

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

<Source_Addr>A</Source_Addr>

<Text>B</Text>

      <TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

         <MM>5</MM>

</ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>&RequestID=1_5838512

I would like to edit payload and take out User/password and RequestID(highlighted in bold) and pass the rest(xml) to message mapping please advise how this an be done

To my understanding this can be achieved by java mapping, please advise if any alternate is possible

Accepted Solutions (0)

Answers (3)

Answers (3)

justin_santhanam
Active Contributor
0 Kudos

Hello Chet,

There are so many examples in the scn. Below one is just an example.

String paramone= "";

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP","URLParamOne");

paramone= conf1.get(key1);

return paramone;

PS: I haven't tested this code, just giving you a hint... Hopefully it helps!

Thanks,

Justin

justin_santhanam
Active Contributor
0 Kudos

Chet,

I think there was a confusion.  I have taken your earlier example data and try to explain. Let us consider the below is data going to be sent from the third party to PI.

http://server:port/HttpAdapter/HttpMessageServlet?interfaceNamespace=sender-interface-namespace&inte...<?xml version="1.0" encoding="UTF-8"? Standalone="no">

<!Doctype Win_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd">

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

<Source_Addr>A</Source_Addr>

<Text>B</Text>

      <TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

         <MM>5</MM>

</ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>&RequestID=1_5838512

If I take the above same message and put it to the any HTTP Client (I'm using POSTMAN). Please see the below results

Now do you agree, TP_XML is one parameter and RequestID is another parameter .. Get the TP_XML as main payload and RequestID as Dynamic Parameter.

Thank you,

Justin.

0 Kudos

Hi Justin,

Many thanks for all info, i am also using postman to test as well, and understand your point, based on that i have passed just one parameter RequestId as parameter(see screen shot below- ignore the response, as proxy not yet created)

values i am passing are


POST -http://server:port/sap/xi/adapter_plain?namespace=urn%3Astw%3Aimi.imimobile.outSMS&interface=SMSRequ...


namespace     urn%3Astw%3Aimi.imimobile.outSMS

interface          SMSRequest_Out

service              servicename

sap-client          clinetnumber

sap-l

RequestID     1_5838512    


Body as 


<?xml version="1.0" encoding="UTF-8"?>

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

      <Source_Addr>A</Source_Addr>

      <Text>B</Text>

      <TransactionID>C</TransactionID>

      <Destination_Addr>D</Destination_Addr>

      <ServiceID>E</ServiceID>

      <NetworkID>F</NetworkID>

      <ArrivalDateTime>

         <DD>1</DD>

         <MMM>2</MMM>

         <YYYY>3</YYYY>

         <HH>4</HH>

         <MM>5</MM>

      </ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>

The HTTP Post works fine


Please could you advise what change i need to do on PI side(comm channel) so as to capture  value of REQUESTid(which is coming as parameter) and where i can see this value in inbound sxmb_moni(inbound message?) 

0 Kudos

I am using HTTP_AAE sender adapter, version 7.4 and set ASMA and set URLparamterOne = RequestID, Where can i see the value for requestid coming in integration engine(from the URL) and how can i use it

justin_santhanam
Active Contributor
0 Kudos

So you are using 7.4 Dual stack, is it? Don't give the "&", just give the parameter name alone RequestID. Go to SXMB_MONI and navigate to the DynamicConfiguration (on the left side of the screen where you can see Inbound Message, etc...). RequestID must have set there. If it's set there, then it's easy for us to retrieve in the  mapping.

Thanks,

Justin.

0 Kudos

Hi Justin

Thank you, it is set , also i have set user id and password as well, my last question(hopefully:), please could you advise how to retrieve it on mapping

cheers

chet

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chet,

             What is the target xml you need from the source xml you mentioned in your first post.

Please can you provide a sample.

Regards

Anupam

0 Kudos

hi anupam

My target xml is an xml which sap PI accepts which is

<?xml version="1.0" encoding="UTF-8"?>

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

      <Source_Addr>A</Source_Addr>

      <Text>B</Text>

      <TransactionID>C</TransactionID>

      <Destination_Addr>D</Destination_Addr>

      <ServiceID>E</ServiceID>

      <NetworkID>F</NetworkID>

      <ArrivalDateTime>

         <DD>1</DD>

         <MMM>2</MMM>

         <YYYY>3</YYYY>

         <HH>4</HH>

         <MM>5</MM>

      </ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>

and my source xml is

User=abc&password=def&TP_XML=<?xml version="1.0" encoding="UTF-8"? Standalone="no">

<!Doctype Win_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd">

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

<Source_Addr>A</Source_Addr>

<Text>B</Text>

      <TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

         <MM>5</MM>

</ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>&RequestID=1_5838512


Extra bits shown in bold


as per justin User=abc&password=def and &RequestID=1_5838512 are parameters, and not part of payload, where the confusion is coming , if i go by justin what solution he has proposed is ok, but as they are part payload and not properly formatted in xml, it fails, so i need to so some kind of mapping before message mapping that properly formats  xml and unformatted xml values like User=abc&password=def and &RequestID=1_5838512 are taken care of 

justin_santhanam
Active Contributor
0 Kudos

Hi Chet,

I'm still saying those three fields are parameters and not the part of the payload. I think I did figure out what's the problem you are facing. The problem is with the below Doctype in your source XML payload from HTTP.  If you remove the below !Doctype, then your issue will be resolved.

<!Doctype Win_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd">

Please take a look at the code provided by @Anupam Ghosh

how to delete DOCTYPE from the message | SCN

All credit goes goes to Anupam..

Thanks!

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chet,

                The part of the payload mentioned in bold if are removed from payload , how are you going to add the same later on. Do you not need those values anywhere else?

You need a simple java mapping to remove these components.

Regards

Anupam

anupam_ghosh2
Active Contributor
0 Kudos

Thank you Justin for mentioning my name in this thread.

I am honoured.  Hope that code works for Chet.

Regards

Anupam

0 Kudos

Hi Anupam

Many Thanks for code, it worked perfectly, few things to complete my scenario( to my understanding need more java code), will summarize below

1. The output after removing DOCTYPE need to be passed to payload(message mapping) for further processing to ECC instead to file(which i am prototying as we speak, still please share if you have one)

final Payload below

<?xml version="1.0" encoding="utf-8"?>

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>

2. Java Code for UserId , Password and Requestid  and TMP&= to be removed from source file to start with please

many thanks for your help

cheers

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chet,

to answer your second question

"2. Java Code for UserId , Password and Requestid  and TMP&= to be removed from source file to start with please"


here it is




import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class RemoveExtraElement  extends AbstractTransformation{

 

  @Override

  public void transform(TransformationInput arg0, TransformationOutput arg1)

  throws StreamTransformationException {

  // TODO Auto-generated method stub

  execute(arg0.getInputPayload().getInputStream(),arg1.getOutputPayload().getOutputStream());

  }

    public void execute(InputStream in, OutputStream out) throws StreamTransformationException

    {

    try

    {

         StringBuilder s = new StringBuilder();

         byte[] b=new byte[in.available()];

        if(in.read(b) >= 0) {

             s = new StringBuilder(s.toString()+new String(b));

       }

      

       int i=s.indexOf("<ns0:SMSRequestMsg_Out");

       if(i>=0)

       {

             int j=s.indexOf("</ns0:SMSRequestMsg_Out>");

             int len="</ns0:SMSRequestMsg_Out>".length();

             s= new StringBuilder(s.substring(i,j+len)).insert(0,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

       }

       System.out.println(s);

       out.write(s.toString().getBytes());

       in.close();

       out.close();

    }   

    catch(Exception e)

    {

         e.printStackTrace();

         throw new StreamTransformationException(e.getMessage());

    }

    }

}

Please can you explain your first question with more details.


Regards

Anupam

0 Kudos

Hi Anupam

Thanks for code code for my second point(above), what i mean by first point is , code i used to remove DOCTYPE(works ok) but uses concept of file( input and output file), but my scenario is , external party will be sending HTTP POST message which will hit integration engine to my understanding(please correct if i am wrong), and java mapping will be triggered first which will take out the DOCTYPE tag

So i need to change the code logice from input/out file to input/output payload, i have modified the code, from logic of file to payload, please have a look and comment:)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chet,

                The  mapping code I gave here in this thread also removes the doctype.  So second question solution is also solution to first one. You do not need any code separately to remove doctype.

Any payload enters java mapping as a file stream . The output of the java mapping is also file stream. Thus mapping has nothing to do with adapters you are using.

Regards

Anupam

0 Kudos

Hi Anupam

Many Thanks for all your help, i think this is my last question sender has confirmed that below is the XML payload that i will get

USER=abc&Password=def&TP_XML=<?xml version="1.0" encoding="utf-8"

standalone="no"?><!DOCTYPE WIN_TPBOUND_MESSAGES SYSTEM

"tpbound_messages_v1.dtd">

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>&RequestID=1_5838512

so to summarize(bold bits need to be either removed or captured)

i have code from you that removes DOCTYPE(works ok) but uses concept of file( input and output file), but my scenario is , external party will be sending HTTP POST message which will hit integration engine to my understanding(please correct if i am wrong), and java mapping will be triggered first which will take out the DOCTYPE tag, so i have changed the code accordingly, screen shot below 

secondly USER=abc&Password=def&TP_XML= &RequestID=1_5838512 need to be removed from source xml and captured for use(as you said earlier), so please advise on the same as well.

please if possible can you help me with one java mapping for all this please

I am new to java code and learning along. Really appreciate all your help.

also would appreciate if you can put few lines what is best way to share a code(as you do), the way i did above is not nice:), i have taken mspaint image

cheers

justin_santhanam
Active Contributor
0 Kudos

Hello Chet,

I think you still didn't get it what I have been explaining for the past 3 days .. You need Java mapping to remove the doc type. You can capture all the parameters in the dynamic headers. Did you actually test this scenario to see how you are receiving the data? can you show us how you actually received in PI? I explained with POSTMAN tool as well, but still you are not accepting that headers won't come in the payload. May be my understanding is not correct. Please show the payload you have received in PI.

Thnx

0 Kudos

hi justin

Many thanks for you patience:) , i will share a exact payload in next few hours, as sorting out the firewall settings and then the third party will be sending a request in

many thanks for bearing me:)

but every time  verbally they are saying , following is payload

USER=abc&Password=def&TP_XML=<?xml version="1.0" encoding="utf-8"

standalone="no"?><!DOCTYPE WIN_TPBOUND_MESSAGES SYSTEM

"tpbound_messages_v1.dtd">

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>&RequestID=1_5838512



justin_santhanam
Active Contributor
0 Kudos

Buddy,

SAP PI is not User Interface - WYSIWYG (What you see is what you get), to me it's the other way around - WYSINWYG(What you see is not what you get ) ... For an example if you go to SXMB_MONI the payload looks all good visually, but if you really look into the source of the payload you can see lot of whitespaces and what not (not always, only if the source data has whitespace just giving you an example)... So, do not believe in it, just execute it and see what's actually the data is. If I'm not confident enough, I won't repeat this again and again, to me it's very simple achievable scenario. We are all talking just different languages (technically)... So run this through and show us what you really got, then we are technically in business. We can help to figure out what needs to be done.

Let me know if it make sense!

Thank you,

Justin.

0 Kudos

hi justin

your are star:), just an update, my firewall setting are complete and i have provided url to the sender , i m hoping to get a inbound message tomorrow will revert

0 Kudos

Hi Anupam/Justin

Many thanks for your patience, i am back:) and urgent help now please.....

Scenario is same --> HTTP(SENDER)-PI-ECC and i have final details

Please find below exact HTTP post and pay load details coming to PI via HTTP

POST Header

/sap/xi/adapter_plain?namespace=urn:stw:imi.imimobile.outSMS&interface=SMSRequest_Out&service=STW_IMI&sap-client=200&sap-l=En&sap-User=chet&sap-password=arora

Host: xx.xxx.xx.xxx

Content-Length: 699

charset: utf-8

Content-Type: application/x-www-form-urlencoded

PAYLOAD to PI

User=abc&password=def&TP_XML=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22no%22%3F%3E%3C%21DOCTYPE+WIN_TPBOUND_MESSAGES+SYSTEM+%22tpbound_messages_v1.dtd%22%3E%3CWIN_TPBOUND_MESSAGES%3E%3CSMSTOTP%3E%3CSOURCE_ADDR%3E%2B447557259949%3C%2FSOURCE_ADDR%3E%3CTEXT%3ESevtest+dwj%40imi+test+20151204+-+1%3C%2FTEXT%3E%3CWINTRANSACTIONID%3E017314492267648647%3C%2FWINTRANSACTIONID%3E%3CDESTINATION_ADDR%3E62277%3C%2FDESTINATION_ADDR%3E%3CSERVICEID%3E1%3C%2FSERVICEID%3E%3CNETWORKID%3E1%3C%2FNETWORKID%3E%3CARRIVALDATETIME%3E%3CDD%3E04%3C%2FDD%3E%3CMMM%3EDEC%3C%2FMMM%3E%3CYYYY%3E2015%3C%2FYYYY%3E%3CHH%3E10%3C%2FHH%3E%3CMM%3E59%3C%2FMM%3E%3C%2FARRIVALDATETIME%3E%3C%2FSMSTOTP%3E%3C%2FWIN_TPBOUND_MESSAGES%3E&RequestID=44141449227102300

Raw XML (just for understanding)

USER=abc&Password=def&TP_XML=<?xml version="1.0" encoding="utf-8"

standalone="no"?><!DOCTYPE WIN_TPBOUND_MESSAGES SYSTEM

"tpbound_messages_v1.dtd">

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>&RequestID=1_5838512

please help me out, i need to remove what is shown in BOLD from payload and capture USER, PASSWORD and REQUESTID for further processing (these three things are not xml tagged but still coming in payload) , hence they call it raw xml

The XML tag for DOCTYPE just need to be removed and not captured , please could you help with the java mapping

also keyword TP_XML= need to be removed as well

Anupam code that you provide earlier to remove values from payload using tag </ns0:SMSRequestMsg_Out> works perfectly and i tried to change it on tag <WIN_TPBOUND_MESSAGES> but does not work out well, as i believe that there are two tags <WIN_TPBOUND_MESSAGES> in payload. Please if it is quick  could provide code just to remove all bold bits( they way you did earlier) that would be great as i will be able to progress on my interface and later provide code to capture(USERID, PASSWORD and REQUESTID)



after java mapping( the raw should look like)

<?xml version="1.0" encoding="utf-8" ?>

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

<USER>abc</USER>

<Password>def</Password>

<RequestID>1_5838512</RequestID>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>

and three captured values to be added to refined xml as shown above)

0 Kudos

Hi Anupam

Many thanks for your help so far i have now processed the  payload , but getting errors

Scenario is --> HTTP (SENDER)-PI-ECC

Please find below  HTTP post and pay load coming to PI via HTTP

POST Header

/sap/xi/adapter_plain?namespace=urn:stw:imi.imimobile.outSMS&interface=SMSRequest_Out&service=STW_IMI&sap-client=200&sap-l=En&sap-User=chet&sap-password=arora

Host: xx.xxx.xx.xxx

Content-Length: 699

charset: utf-8

Content-Type: application/x-www-form-urlencoded

PAYLOAD to PI

User=abc&password=def&TP_XML=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22no%22%3F%3E%3C%21DOCTYPE+WIN_TPBOUND_MESSAGES+SYSTEM+%22tpbound_messages_v1.dtd%22%3E%3CWIN_TPBOUND_MESSAGES%3E%3CSMSTOTP%3E%3CSOURCE_ADDR%3E%2B447557259949%3C%2FSOURCE_ADDR%3E%3CTEXT%3ESevtest+dwj%40imi+test+20151204+-+1%3C%2FTEXT%3E%3CWINTRANSACTIONID%3E017314492267648647%3C%2FWINTRANSACTIONID%3E%3CDESTINATION_ADDR%3E62277%3C%2FDESTINATION_ADDR%3E%3CSERVICEID%3E1%3C%2FSERVICEID%3E%3CNETWORKID%3E1%3C%2FNETWORKID%3E%3CARRIVALDATETIME%3E%3CDD%3E04%3C%2FDD%3E%3CMMM%3EDEC%3C%2FMMM%3E%3CYYYY%3E2015%3C%2FYYYY%3E%3CHH%3E10%3C%2FHH%3E%3CMM%3E59%3C%2FMM%3E%3C%2FARRIVALDATETIME%3E%3C%2FSMSTOTP%3E%3C%2FWIN_TPBOUND_MESSAGES%3E&RequestID=44141449227102300

step 1: I am using Java mapping for url decoder, first to decode encoded URL

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class Java_Url_Decoder extends AbstractTransformation{

  

   @Override

   public void transform(TransformationInput arg0, TransformationOutput arg1)

   throws StreamTransformationException {

   // TODO Auto-generated method stub

   execute(arg0.getInputPayload().getInputStream(),arg1.getOutputPayload().getOutputStream());

   }

     public void execute(InputStream in, OutputStream out) throws StreamTransformationException

     {

     try

     {

         String url = in.toString();

            String s = java.net.URLDecoder.decode(url, "UTF-8");

         System.out.println(s);

        in.close();

        out.close();

     }   

     catch(Exception e)

     {

          e.printStackTrace();

          throw new StreamTransformationException(e.getMessage());

     }

     }

  }

Next step, I using a parser to convert values to target structure (shown below), but getting an error Error when parsing an XML document (Premature end of file.)

Please help me in getting correct code to implement the scenario i.e. decode, removing values shown in red and parsing please(capturing values shown in green in target structure) for the payload above

Source Raw XML (For understanding only)

USER=abc&Password=def&TP_XML=<?xml version="1.0" encoding="utf-8"

standalone="no"?><!DOCTYPE WIN_TPBOUND_MESSAGES SYSTEM

"tpbound_messages_v1.dtd">

<WIN_TPBOUND_MESSAGES>

<SMSTOTP>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<WINTRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

<DD>19</DD>

<MMM>NOV</MMM>

<YYYY>2004</YYYY>

<HH>11</HH>

<MM>4</MM>

</ARRIVALDATETIME>

</SMSTOTP>

</WIN_TPBOUND_MESSAGES>&RequestID=1_5838512

Target structure

<SMSRequesstDt>

<SMSREQUEST>

<SOURCE_ADDR>+447740630138</SOURCE_ADDR>

<TEXT>bulktesth2</TEXT>

<TRANSACTIONID>357614643</WINTRANSACTIONID>

<DESTINATION_ADDR>82222</DESTINATION_ADDR>

<SERVICEID>2</SERVICEID>

<NETWORKID>2</NETWORKID>

<ARRIVALDATETIME>

     <DD>19</DD>

     <MMM>NOV</MMM>

     <YYYY>2004</YYYY>

     <HH>11</HH>

     <MM>4</MM>

</ARRIVALDATETIME>

<USER>abc</USER>

<Password>def</Password>

<RequestID>1_5838512</RequestID>

</SMSREQUEST>

</SMSRequesstDt>

And three captured values to be added to refined xml as shown above

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chet,

                Your requirement is too complex. I am trying to find a solution to it. Please wait for 1 more day. I am close to the solution.

Regards

Anupam

justin_santhanam
Active Contributor
0 Kudos

Hi,

What is your PI version? You don't need Java mapping. You can achieve this using HTTP sender adapter.

See point 6

https://help.sap.com/saphelp_nw73ehp1/helpdata/en/03/e2d70a626342feaef7f2f9f04a1776/content.htm

If the HTTP input is through the form submission, choose Set Form and enter the Main Payload Parameter Name to specify the name of the request parameter whose value should be copied to the XI main payload.


See below

HTTP Requests Supported by the Java HTTP Adapter - Advanced Adapter Engine - SAP Library

Form Submit Request : It indicates that the HTTP POST request is a form submit request. Content type for this scenario is 'application/x-www-form-urlencoded'. You use this scenario to select the XI main message payload from one of the parameters of the form submit request.



So based on your information you have to set SET FORM as TP_XML



PS: I have never did this, but based on the above references its easily achievable.

Thank you,

Justin.


0 Kudos

Hi Justin


I am on PI 7.4 and using HTTP sender adapter and not HTTP_AAE(would you recommend me using this?)

cheers

justin_santhanam
Active Contributor
0 Kudos

Okay, then it should be possible. Give a try and  let us know!

0 Kudos

Hi Justin

I changed adapter type to HTTP_AAE and passed payload is now more stripped version(just to test)

and set the "set form" and value of Main Paoload parameter name  = "TP_XML" and still fails at message mapping

TP_XML=<?xml version="1.0" encoding="UTF-8"? Standalone="no">

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

<Source_Addr>A</Source_Addr>

<Text>B</Text>

      <TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

         <MM>5</MM>

</ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>

Message mapping error is "mapping general error"

any further thoughts

justin_santhanam
Active Contributor
0 Kudos

Can you copy the payload coming into PI and test it with Message mapping to see if it works? Probably name space issues??

Justin

0 Kudos

Hi Justin

That is correct, message mapping does not work as it expects properly tagged version of xml payload which is

<?xml version="1.0" encoding="UTF-8"?>

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

      <Source_Addr>A</Source_Addr>

      <Text>B</Text>

      <TransactionID>C</TransactionID>

      <Destination_Addr>D</Destination_Addr>

      <ServiceID>E</ServiceID>

      <NetworkID>F</NetworkID>

      <ArrivalDateTime>

         <DD>1</DD>

         <MMM>2</MMM>

         <YYYY>3</YYYY>

         <HH>4</HH>

         <MM>5</MM>

      </ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>

and fails if the payload is

User=abc&password=def&TP_XML=<?xml version="1.0" encoding="UTF-8"? standalone="no">

<!Doctype Win_TPBOUND_MESSAGES SYSTEM "tpbound_messages_v1.dtd">

<ns0:SMSRequestMsg_Out xmlns:ns0="urn:stw.wfm.imisms">

   <smsrequest>

<Source_Addr>A</Source_Addr>

<Text>B</Text>

<TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

<MM>5</MM>

</ArrivalDateTime>

   </smsrequest>

</ns0:SMSRequestMsg_Out>&RequestID=1_5838512

All bits that are giving a concern ar shown in bold(need to be handled before going into message mapping , i believe)

Ps: I have done message mapping for fields

<Source_Addr>A</Source_Addr>

<Text>B</Text>

<TransactionID>C</TransactionID>

<Destination_Addr>D</Destination_Addr>

<ServiceID>E</ServiceID>

<NetworkID>F</NetworkID>

<ArrivalDateTime>

<DD>1</DD>

<MMM>2</MMM>

<YYYY>3</YYYY>

<HH>4</HH>

<MM>5</MM>

</ArrivalDateTime>

0 Kudos

Hi Justin

Further observation,  if the payload contains standalone="no"(as shown in bold), it fails

<?xml version="1.0" encoding="UTF-8"? standalone="no">

is Java mapping the solution to this, or am i missing anything

Cheers

justin_santhanam
Active Contributor
0 Kudos

Hi Chet,

>>>and fails if the payload is


Your XML payload  coming into the mapping will never have those additional query parameters. That's the whole point of using HTTP adapter correct? We are specifying in the channel, that my xml_payload should be taken from Query Parameter = TP_XML. So there won't be any other additional query values coming into the mapping. The problem is something different. Can you log /store the steps in ICO ? See each step log before going to mapping program what's the payload looks like..


Thank you,

Justin.

0 Kudos

Hi Justin

Will do and agree to your point, that if we are specifying Query Parameter = TP_XML no other values should be coming to payload prior to that, but if you see payload which i have mentioned above , there are few things after "Tp_XML"(at the end) which PI does not like for example

</ns0:SMSRequestMsg_Out>&RequestID=1_5838512


There is "requestID" which is coming in end and we need to capture that , and sender is not ok to send as part of proper xml payload, hence i believe that java mapping is needed to clean, strip and capture out bits that are coming in payload but not part of proper payload format



0 Kudos

or else there is some way from PI end to capture information like &RequestID=1_5838512 which is appearing at end of payload, any suggestions please ?

justin_santhanam
Active Contributor
0 Kudos

.. There is always some options

Please take a look at Step 10

Configuring the Java HTTP Adapter on the Sender Channel - Advanced Adapter Engine - SAP Library

Store the Request ID in ASMA. Later we can retrieve it in Message mapping.

Thank you

Justin.

0 Kudos

Hi Justin

Thank You , just tried but no luck , as they are not part of header, they are part of payload from the sender side, any more thaughts:) , suggestions 

cheers

0 Kudos

Point 10 of document says

  • f you want to copy the HTTP header values into XI dynamic headers, choose HTTP Header Fields and enter the HTTP header names in the corresponding fields namely HTTP Header Fields (Field 1 (HeaderFieldOne),....,Field 6 (HeaderFieldSix))
  • If you want to copy the HTTP URL parameters as XI dynamic headers, choose URL Parameters and enter the HTTP URL parameter names that map to their respective dynamic headers in the corresponding URL parameter field namely URL Parameters (Parameter 1 (URLParamOne),...Parameter6(URLParamSix)) .

In my case they are not part of HTTP header or HTTP URL, it is part of body(payload-XML)

please let me know if i am missing something

justin_santhanam
Active Contributor
0 Kudos

How you say RequestID is part of payload XML? Did you see the parameters ? RequestID is not the part of TP_XML, RequestID is just another query parameter just like TP_XML.


&RequestID =

Thank you,

Justin,

0 Kudos

HI Justin

Fully agree with you, looking at details Requestid does not look to be part of payload xml, but i have checked with sender and they confirm that this is raw xml and this is how they will be sending, i need to adjust it. and hence Requestid, username and password  is part of xml payload

PLease suggest how to extract and isolate from payload