cancel
Showing results for 
Search instead for 
Did you mean: 

http adapter metadata in java mapping

Former Member
0 Kudos

Hi, I'd like to read the httpheaders in my java mapping.

How can this be done?

I have tried the follwing in the execute method

trace = (AbstractTrace)param.get(

StreamTransformationConstants.MAPPING_TRACE);

DynamicConfiguration dc = (DynamicConfiguration)param.get(

StreamTransformationConstants.DYNAMIC_CONFIGURATION);

Object obj = (Object) param.get(

StreamTransformationConstants.CONTENT_TYPE);

trace.addInfo(obj.getClass().toString());

//

// namespace http://sap.com/xi/XI/System/File

// propertyname Directory, Filename

trace.addInfo("Start");

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

//

//trace.addInfo("has key httpHeader");

Iterator it = dc.getKeys();

while (it.hasNext()) {

DynamicConfigurationKey el = (DynamicConfigurationKey) it.next();

trace.addInfo(el.getNamespace() + " " + el.getName());

if (el.getNamespace().equals("http://sap.com/xi/XI/System/HTTP") ){

if (el.getName().equals("httpHeader") ){

}

}

}

//if (dc.containsKey(dck)) {

//}

trace.addInfo("After dyn conf");

No keys are found.

Hope someone can help

Best regards /Otto

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Otto,

Are you trying to read headers/information from the HTTP request or from the response?

In case you want to access runtime constants (like message ID, party, processing mode, time_sent, sender, receiver, etc..) you can use the runtime constants map. See this link for more info:

http://help.sap.com/saphelp_nw04/helpdata/en/f4/8620c6b58c422c960c53f3ed71b432/frameset.htm

Former Member
0 Kudos

Hello, thanks for your help.

I have the following in my trace in the log SXMB_MONI

Depending on the charset and the content-type I'd like to take different action.

I use a visualbasic script to send a file to XI.

This file may be xml, zip, text or whatever. In this test I used a utf-8 text file. XI can put it into the pipe binary clean, and then I use a java program to unpack it and wrap it in xml for further processing. The file is put in the http post data, which is by definition binary clean.

Of course I can not route on a binary file, so I have to configure routing etc appropriately.

Looks like the trace api only allows for writing to the trace, not reading.

Best regards /Otto

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

- <!-- Technical Routing

-->

- <SAP:Trace xmlns:SAP="http://sap.com/xi/XI/Message/30">

- <Trace level="1" type="B" name="CL_HTTP_PLAIN_INBOUND">

<Trace level="1" type="T">server-protocol HTTP/1.1</Trace>

<Trace level="1" type="T">content-type text/plain; charset=UTF-8</Trace>

<Trace level="1" type="T">charset charset=UTF-8</Trace>

<Trace level="1" type="T">user-agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)</Trace>

<Trace level="1" type="T">host skxidev:8000</Trace>

<Trace level="1" type="T">content-length 10</Trace>

<Trace level="1" type="T">remote-addr 10.206.97.89</Trace>

</Trace>

Former Member
0 Kudos

I use a visualbasic script to send a file via http to xi.

Former Member
0 Kudos

AS far as I know the HTTP adapter is not part of the J2EE adapter framework (i.e. it does not run on top of the JAVA runtime). This adapter and also the IDOC adapter runs under the ABAP engine of XI. SO I think if you want to get the values on those specific HTTP headers then you might want to look at the ABAP level or include these header values somehow in the payload handled to XI. That way you can have access to them. You might also want to look at the new features of this adapter in the newest SP14, which also includes the use of user-defined properties in some adapters.

Good Luck!

Roberto.

Message was edited by: Roberto Viana

Former Member
0 Kudos

Hello again,

it looks like the plainhttpadapter actually sets the content_type.

It should be possible to do something like:

String content_type = (String) param.get(

StreamTransformationConstants.CONTENT_TYPE);

trace.addInfo("content-type " + content_type);

But that doesn't work, because the abap class just sets the content_type at the payload, not among the parameters, even though that is what you'd expect. Is this a bug or missing feature?.

The payload actually has the content-type set, because when looking in the log, under the "Payloads" folder MainDocument, the content-type actually shows up.

Now the question is, how do I access the payloads content-type from the java mapping? As the parameter is not set.

Best regards /Otto

Former Member
0 Kudos

Pauloads should of course be Payloads.

We use SP14.

You'd expect the adaptermetadata to be set in SP14, but that's not it

/Otto

Answers (0)