cancel
Showing results for 
Search instead for 
Did you mean: 

Authenticate with TokenUser & Password in SOAP header

former_member217029
Participant
0 Kudos

Hello,

My requirement is to send Idoc information to SOAP receiver system with Tokenuser & password in soap header to authenticate the web service call.

My web service structure is as below when i open wsdl file in soap ui. I am able to get response back when i trigger from soap ui.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="https://www.xyz.com/WebServices/WebMethods">

   <soapenv:Header>

      <web:ValidationSoapHeader>

         <!--Optional:-->

         <web:TokenUser>?</web:TokenUser>

         <!--Optional:-->

         <web:TokenPassword>?</web:TokenPassword>

      </web:ValidationSoapHeader>

   </soapenv:Header>

   <soapenv:Body>

      <web:SendData>

         <!--Optional:-->

         <web:argBase64>?</web:argBase64>

         <!--Optional:-->

         <web:argStr1>?</web:argStr1>

      </web:SendData>

   </soapenv:Body>

</soapenv:Envelope>

I have convert whole IDOC to base64 encode and mapp to argBase64 field in the body. This portion is complete.

Regarding TokenUser & Password I am referring to below blog to add soap header information. Could you please let me know what are the parameters should be maintained to add soap envelope as mentioned above  ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

Hi Bhavana,

The SOAP envelop will be prepare by the adapter, just make sure do not tick the option of "do not use soap envelop". Then when you add the module "AddSOAPHeaderBean" and specify the values for the parameter authenticationHdr then it will add the header.

are you facing any issue while testing this?

regards,

Harish

former_member217029
Participant
0 Kudos

Hello,

Thanks for the inputs.

I am getting below error when i trigger Idoc from RWB. But when i send using SOAP UI, its perfectly alright and no issues.

Transmitting the message to endpoint <local> using connection AFW failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.sdk.xi.net.exception.HttpException: User is not authorized! HTTP 401 Authorization Required


When i take look at soap receiver side payload, i see below 2 issues

1. soap envelope it's not getting added( I did not selected Do not use SOAP Envelope in receiver channel and followed below blog to add soap envelope

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/11/22/addsoapheaderbean-module

2. ns0 added in the payload. I am using below document to remove namespace from payload but its not happening.

https://scn.sap.com/community/pi-and-soa-middleware/blog/2014/10/02/remove-namespace-by-

xmlanonymizer-bean-in-communication-channel

Am i missing anything here ?

manoj_khavatkopp
Active Contributor
0 Kudos

1. soap envelope it's not getting added( I did not selected Do not use SOAP Envelope in receiver channel and followed below blog to add soap envelope

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/11/22/addsoapheaderbean-module

You wont be able to see the soap envelope in RWB payload if you want to see the final payload i.e soap envelope built by soap adapter then you need to enabled http parameter in soap receiver channel :

For 401 Authorization : i hope you have maintained user id and password in channel level too and also make sure you have maintained in AddSoapHeaderBean too.

Please provide screenshot of the soap ui and also the soap channel config.

former_member217029
Participant
0 Kudos

Hello Manoj,

Thanks for your inputs....I am able to get add soap envelope using xslt mapping. In operation mapping i gave message mapping first and then xslt mapping.

Now the issue is i would like to remove namespace "ns0" from PI mapping output that is sending to third party web service call using below thread but its not working.

Can you please let me know what would be the issue?

https://scn.sap.com/community/pi-and-soa-middleware/blog/2014/10/02/remove-namespace-by-

xmlanonymizer-bean-in-communication-channel

SOAP receiver config:

Processing sequence:

AF_Modules/XMLAnonymizerBean     Local Enterprise Bean     1

sap.com/com.sap.aii.af.soapadapter/XISOAPAdapterBean     Local Enterprise Bean     soap

Module Config:

1     anonymizer.acceptNamespaces     http://www.w3.org/2001/XMLSchema-instance xsi http://www.w3.org/2001/XMLSchema xsd http://schemas.xmlsoap.org/soap/envelope soap https://www.xyz.com/WebServices/WebMethods ''(2 single quotes)

soap     anonymizer.quote     '(single quote)

Currently my soap request from PI is like below:

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

-<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">-<soap:Header>-<ValidationSoapHeader xmlns="https://www.xyz.com/WebServices/WebMethods"><TokenUser>user</TokenUser><TokenPassword>pwd</TokenPassword></ValidationSoapHeader></soap:Header>-<soap:Body>-<ns0:SendData xmlns:ns0="https://www.xyz.com/WebServices/WebMethods"><ns0:argConteudoBase64>IDOC XML base64 data</ns0:argConteudoBase64><ns0:argStrEmissor>data</ns0:argStrEmissor></ns0:SendData></soap:Body></soap:Envelope>

I want to remove namespace from soap body any how i don't have namespace(ns0) issue with soap envelope.

Regards

manoj_khavatkopp
Active Contributor
0 Kudos

I just tried this and it is working :

Input :


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

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Header>

<ValidationSoapHeader xmlns="https://www.xyz.com/WebServices/WebMethods">

<TokenUser>user</TokenUser>

<TokenPassword>pwd</TokenPassword>

</ValidationSoapHeader>

</soap:Header>

<soap:Body>

<ns0:SendData xmlns:ns0="https://www.xyz.com/WebServices/WebMethods">

<ns0:argConteudoBase64>IDOC XML base64 data</ns0:argConteudoBase64>

<ns0:argStrEmissor>data</ns0:argStrEmissor>

</ns0:SendData>

</soap:Body>

</soap:Envelope>

Output:

Module:

anonymizer.acceptNamespaces = http://www.w3.org/2001/XMLSchema-instance xsi  http://www.w3.org/2001/XMLSchema xsd  http://schemas.xmlsoap.org/soap/envelope/ soap  https://www.xyz.com/WebServices/WebMethods ''

anonymizer.quote = '

Br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

Where are you seeing this output? in RWB ? Does it display in SOAP receiver payload ?


I gave exactly same as mentioned in receiver soap channel but i am not able to see removing ns0 in payload.

Regards

manoj_khavatkopp
Active Contributor
0 Kudos

I tried with sender File channel.

To see the payload after XMLAnonymizerBean add another module below that MessageLoggerBean and trigger a message and open the message in message monitoring you should be able to see data after anonymizerbean.

Paste the otput after message mapping and also paste the exact parameters you mentioned in the module here to analyze further.

Br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

Let me summarize this interface what i have done so far and what is the current issue that i am facing.

This is Idoc->PI->SOAP Async interface. I have to convert whole Idoc to Base64 and mapp it to one of the target field. And also pass token user & password in soap header to authenticate the web sevice call.

1) I used udf to convert whole idoc to base64 and mapp to one of the target field.

2) used xslt mapping to add soap envelope and in operation mapping i am calling message mapping first and then xslt mapping.

I am able to convert whole idoc to base64 content and able to add soap header as well when i check the payload in RWB. The error that i am getting right now is like below...

SOAP: Error occurred: com.sap.engine.interfaces.messaging.api.exception.MessagingException: SOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 415 Unsupported Media Type

Exception caught by adapter framework: SOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 415 Unsupported Media Type

Transmitting the message to endpoint <local> using connection AFW failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: SOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 415 Unsupported Media Type


Below is the payload that i am seeing from RWB, it would be the payload that will be feeding to web service call

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soap:Header>

      <ValidationSoapHeader xmlns="https://www.xyz.com/WebServices/WebMethods">

         <TokenUser>user</TokenUser>

         <TokenPassword>password</TokenPassword>

      </ValidationSoapHeader>

   </soap:Header>

   <soap:Body>

      <ns0:SendData xmlns:ns0="https://www.xyz.com/WebServices/WebMethods">

         <ns0:argConteudoBase64>IDOC Test data</ns0:argConteudoBase64>

         <ns0:argStrEmissor>CHINA</ns0:argStrEmissor>

      </ns0:SendData>

   </soap:Body>

</soap:Envelope>


So here i want to deal with 2 things

1) Remove ns0 from soap body. Used below configuration in soap receiver channel

2) Above error saying that issue with soap response, it is because i configured it as Async interface. So i wanted to ignore soap response from Target system so i asked web service system to don't send response back they told ok but still i am getting above error.

I know i can follow this blog to handle response in PI but i wanted to make sure web service system itself suppress the response from their end.

http://scn.sap.com/community/pi-and-soa-middleware/blog/2011/03/07/unleash-synchronous-scenarios

manoj_khavatkopp
Active Contributor
0 Kudos

1.XMLAnonymizer bean should work .

2. My suggestion try with soap UI then check the header of the request usually http 415 is because of wrong content type. usually there will be a response from web-service which would be an empty soap envelope.

As you have constructed soap envelope and i hope you have checked "Do not use soap envelope" in the receiver channel in this case soap adapter sets the content type to application/xml ,which you can change by using MTB.

former_member217029
Participant
0 Kudos

Hello Manoj,

Yes i checked do not use soap envelope in soap receiver channel.

May i know the parameter details that i have to use to change the content type ?

when i make a web service call from SOAP UI by importing wsdl,  I am seeing below response

Below is the module configuration in soap receiver channel

manoj_khavatkopp
Active Contributor
0 Kudos

Few suggestions:

Check the RAW tab in SOAP UI to check the request headers like (Content-type , content -length etc..) So set the same content type in your channel using MTB.

Moduel: Message TransformBean

Parameter :Transform.ContentType

Parameter-Value : <Content-type which you see in RAW tab of the request in soap U eg:text/xml;utf-8>

In XMLAnonymizerbean the namespace http://schemas.xmlsoap.org/soap/envelope

is missing '/' add this in your module it should be http://schemas.xmlsoap.org/soap/envelope/

Execute and cross the payload in messageloggerbean with the soap UI request , both should match exactly.

Br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

I see below information from RAW tab of soap ui

POST http://xyz.com/net/WebServices/WebMethods.asmx HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "https://www.xyz.com/WebServices/WebMethods/SendData"

Content-Length: 689

Host: xyz.com

Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

So parameter value would be just "UTF-8"  ??  And what sequence it should follow?

Thanks

former_member217029
Participant
0 Kudos

Hello,

I have used below parameters and the message is success.

Used this just before standard module name is being called.

localejbs/AF_Modules/MessageTransformBean    

Transform.ContentType     text/xml

But i am still seeing ns0 in the payload.

Some how to remove ns0 is not working !!

Below are the parameters used:

Payload:

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

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soap:Header>

      <ValidationSoapHeader xmlns="https://www.xyz.com/WebServices/WebMethods">

         <TokenUser>user</TokenUser>

         <TokenPassword>pwd</TokenPassword>

      </ValidationSoapHeader>

   </soap:Header>

   <soap:Body>

      <ns0:SendData xmlns:ns0="https://www.xyz.com/WebServices/WebMethods">

         <ns0:argConteudoBase64>Test data</ns0:argConteudoBase64>

         <ns0:argStrEmissor>CHINA</ns0:argStrEmissor>

      </ns0:SendData>

   </soap:Body>

</soap:Envelope>

Answers (1)

Answers (1)

former_member190293
Active Contributor
0 Kudos

Hi Bhavana!

As per mentioned blog you should add two parameters:

namespace = "https://www.xyz.com/WebServices/WebMethods"

ValidationSoapHeader="<TokenUser>YourUserName</TokenUser><TokenPassword>YourUserPassword</TokenPassword>".

If you want to hide token details in module parameters use pwd.ValidationSoapHeader as parameter name.

Regards, Evgeniy.