cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP Sender and Dynamic Configuration

Former Member
0 Kudos

Hello guys!

I have a third-party system making HTTP Requests to SAP PI 7.0 (http://<server>:<port>/sap/xi/adapter_plain). I have created a HTTP Sender Adapter and Sender Agreement because I need to change the content-type of PI's HTTP Response from "application/xml" (PI's default) to "application/soap+xml" (this third-party system does not understand "application/xml").

I have created a XSLT mapping and configured the HTTP Sender as in the images bellow! But it is not working! Any guess?

Accepted Solutions (1)

Accepted Solutions (1)

nageshwar_reddy
Contributor
0 Kudos

What is not working? Do you see any error message? Is the problem only in response?

I have created a XSLT mapping and configured the HTTP Sender as in the images bellow! But it is not working! Any guess?

Former Member
0 Kudos

Actually, there is no error in PI! It sends a response to the HTTP client! But since my configuration and mapping did not work (the content-type of the response did not change from "application/xml" to "application/soap+xml) the client refuses it with an error message ("Client found response content type of 'application/xml', but expected 'application/soap+xml'").

nageshwar_reddy
Contributor
0 Kudos

Julio,

Can you use "type" instead of "content-type" and check? Also, can you paste the raw HTTP response you that is being rejected? I want to see the header parameters...

Other thing i can think of is, use "Content-Type" being case sensitive.

Message was edited by: Nageshwar Reddy

Former Member
0 Kudos

Hi Reddy! I just have tried with "type" but it did not change anything!

This the HTTP Response:

 

HTTP/1.1 200 OK

content-type: application/xml

content-length: 1032

msgguid: 502503AE5D3F0DA0E1008000AC10152F

server: SAP NetWeaver Application Server / ABAP 700

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

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeCancelamento2"><cUF/><versaoDados>2.00</versaoDados></nfeCabecMsg></soap:Header><soap:Body><nfeCancelamentoNF2Result xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeCancelamento2"><ns1:retCancNFe xmlns:ns1="http://www.portalfiscal.inf.br/nfe" versao="2.00"><ns1:infCanc Id="ID33120833000092004660550010001049621064638988"><ns1:tpAmb>2</ns1:tpAmb><ns1:verAplic>SVRS20110530105153</ns1:verAplic><ns1:cStat>101</ns1:cStat><ns1:xMotivo>Evento registrado e vinculado a NF-e</ns1:xMotivo><ns1:cUF>33</ns1:cUF><ns1:chNFe>33120833000092004660550010001049621064638988</ns1:chNFe><ns1:dhRecbto>2012-08-07T11:28:19-03:00</ns1:dhRecbto><ns1:nProt>333120000473615</ns1:nProt></ns1:infCanc></ns1:retCancNFe></nfeCancelamentoNF2Result></soap:Body></soap:Envelope>

nageshwar_reddy
Contributor
0 Kudos

Hi Julio,

I used a UDF and I  was able to set the content-type. Here is the result.

----------------HEADERS--------

set-cookie: sap-usercontext=sap-language=EN&sap-client=001; path=/

content-type: application/soap+xml

content-length: 1662

msgguid: 5063BAE2E32E11E198450000005298BA

server: SAP NetWeaver Application Server / ABAP 730

Here is the UDF code

  public String setHttpHeader(String contenttype, Container container) throws StreamTransformationException{

  // beginning of setHttpHeader d2a0e4bf0852e83b928c90e621036c29

        String funcName = "setHttpHeader ";

        // get trace object using container

        AbstractTrace trace = container.getTrace();

        trace.addInfo(funcName + "called with  value - " + contenttype);

        // Get dynamic configuration object

        trace.addDebugMessage(funcName + "getting dyncamic configurtion ");

        DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get

                         (StreamTransformationConstants.DYNAMIC_CONFIGURATION);

        // If dynamic configuration object is null, return

        if(conf == null){

            trace.addInfo(funcName + "Unable to get dyncamic configurtion. Returning. ");

            return contenttype;

        }

        // Create the dynamic configuration key

        trace.addDebugMessage(funcName + "creating dyncamic configurtion key HeaderFieldOne");

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

        if(key == null){

            trace.addInfo(funcName + "Unable to create configurtion key HeaderFieldOne. Returning.");

            return contenttype;

        }

        // set the HeaderFieldOne key value

        trace.addDebugMessage(funcName + "setting value " + key.toString() + " "+ contenttype);

        conf.put(key, contenttype);

        return contenttype;

  // end of setHttpHeader d2a0e4bf0852e83b928c90e621036c29

  }

Sender configuration remains same:

Let me know if this works for you.

Former Member
0 Kudos

Hello, Nageshwar! Thank you again for your reply! Unfortunatelly, it did not work yet! Looking at trace information everything looks fine, but my HTTP response is still "application/xml"

- <MappingTrace>

<Trace level="1" type="T">Mapping-Namespace:urn:cosan.com.br/xi/cancelamento</Trace>

<Trace level="1" type="T">Mapping-Name:formatCancNFe</Trace>

<Trace level="1" type="T">Mapping-SWCV:8E2A00802BB011DFCB22D103AC101552</Trace>

<Trace level="1" type="T">Mapping-Step:1</Trace>

<Trace level="1" type="T">Mapping-Type:JAVA</Trace>

<Trace level="1" type="T">Mapping-Program:com/sap/xi/tf/_setContentType_</Trace>

<Trace level="1" type="T">*** START APPLICATION TRACE ***</Trace>

<Trace level="1" type="T">setHttpHeader called with value application/soap+xml</Trace>

<Trace level="1" type="T">setHttpHeader getting dynamic configuration</Trace>

<Trace level="1" type="T">setHttpHeader creating dynamic configuration key HeaderFieldOne</Trace>

<Trace level="1" type="T">setHttpHeader setting value <namespace>http://sap.com/xi/XI/System/HTTP</namespace><name>HeaderFieldOne</name> application/soap+xml</Trace>

<Trace level="1" type="T">Content Type application/xml</Trace>

</MappingTrace>

nageshwar_reddy
Contributor
0 Kudos

Hi Julio,

Where are you calling the mapping/udf? I hope you are calling it in the response message mapping. Do you see the value in the dynamic configuration node after the response message mapping? See the attached screenshot and check your system...

Former Member
0 Kudos

I am working with a sync-async bridge! I am calling the UDF in the Transformation Step that generates the message that closes the bridge!

The dynamic configuration node looks exactly like yours!

Former Member
0 Kudos

nageshwar_reddy
Contributor
0 Kudos

Good to know that it worked. Have a good day.

Former Member
0 Kudos

Both the UDF and the XSLT mapping worked! The problem really was the place where I was using the Interface Mapping!

former_member332548
Discoverer
0 Kudos

Hi Julio,

i have the same Problem to Change the Content-type in a http Response from Standard application/XML to text/XML. I set the Parameter with a xslt Transformation and see it in dynamicConfiguration, but on Client side we receive always application/XML .CoulI dont'Ä

I dont' t understand your Change the get this working. Could you please help me ?

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

IMO the content type application/soap+xml is soap 1.2 based.  I'm not positive about HTTP Adapter of version PI 7.0 supports this. You might want to try SOAP AXIS adapter (as simple adapter without using the option soap envelope and as just plain http adapter) and see if that helps.

Former Member
0 Kudos

Gopalakrishnan, I am using HTTP plain adapter because, unfortunatelly, the HTTP client (third-party system) can not authenticate against PI server, so it is sending user and password as URL parameters (&sap-user=xxx&sap-password=yyy).

If I could send user and password to SOAP Adapter as URL parameters (I have tested it, but it did not work), my problem would be solved, because in SOAP Adapter Module I can set the content-type to "application/soap+xml"

baskar_gopalakrishnan2
Active Contributor
0 Kudos

refer stefan blogs about how webservice client passing  the soap message directly to integration engine

http://scn.sap.com/people/stefan.grube/blog/2006/09/21/using-the-soap-inbound-channel-of-the-integra...

You might also pass user and password as follows.. example...

http://<hostname>:<port>/sap/xi/engine?type=entry&amp;version=3.0&amp;Sender.Service=<XXX>&amp;Inter...QualityOfService=BE&amp;

sap-client=100&sap-user=user&sap-password=pwd

Former Member
0 Kudos

Hi Gopalakrishnan! First of all, I really appreciate your help!

Well, I've already read Stefan's blog and I've already tried to use the URL of the integration engine. It didn't work either, because HTTP Client uses SOAP 1.2 and the Integration Engine returns an error ("SOAP_ENVELOPE_INVALID: Invalid SOAP envelope due to error in node SOAP:Envelope").