cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver web service call with userToken in SOAP header

former_member217029
Participant
0 Kudos

Hello All,

I have a requirement to call third party web service and use userToken and password in soap header(Idoc-->PI-->Web Service).

When i import the provided wsdl file in to PI under external definitions i have the structure like below(Screen)

1) They asked us to convert Idoc xml to a binary base64 and send to field name called "argBytConteudo" which is not there in wsdl structure.

2) Also they asked us to send additional parameters like system date/Time & some fixed constant values. Their received dataset parameters should be below format.

I am confused how to use a field name called "argBytConteudo" which is not part of the wsdl structure.And also how to pass these additional parameters through soap adapter & how to pass userToken/password in the soap header.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

manoj_khavatkopp
Active Contributor
0 Kudos

1. You see these filed missing because you have not imported the external XSD in your screenshot you can see the red color , so you need to import this xsd .ask the web-service guy's and you will see that field. OR how about putting the target URL in browser and downloading the WSDL file try this.

2.Once you import the other CSD you will see other fields.

To pass userToken/Password in soap heade ryou may use AddSoapHeaderBean/JAVA/XSLT mapping you will find a lot in scn for this.

Br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

Thanks for your valuable inputs.

>>>1. You see these filed missing because you have not imported the external XSD in your screenshot you can see the red color , so you need to import this xsd .ask the web-service guy's and you will see that field. OR how about putting the target URL in browser and downloading the WSDL file try this.


I will ask them to provide xsd's. Once i get XSD i hope i will see those all fields. Then to convert the whole Idoc xml to binary base64 and mapp to one of the field would be achieved by a small piece of UDF(Below).


public String base64Encode(String str, Container container) throws StreamTransformationException

{

try{

  byte[]   bytesEncoded = Base64.encode(str.getBytes("utf-8"));

  return new String(bytesEncoded );

} catch ( UnsupportedEncodingException e ) {

  return "Error";

}

}

>>>To pass userToken/Password in soap heade ryou may use AddSoapHeaderBean/JAVA/XSLT mapping you will find a lot in scn for this.


To use userToken/Password, How about using parameters concept in message mapping/Operation mapping and assign values to the parameters in the interface determination editor in the Integration Directory? 


Regards

Bhavana

manoj_khavatkopp
Active Contributor
0 Kudos

Yes the UDF looks fine to convert but a small suggestion its not  good to use SUN's jar file for Base64 as this is suppressed you may use standard SAP provided JAR for Base64 jar com.sap.aii.utilxi.core.jar.

SOAP Envelope has 2 main parts :

SOAP Header : To add any data in this you need to build a custom soap envelope using above mentioned methods.

SOAP BODY : which contain the main data , so the output of the MM will be considered as soap body and then soap adapter builds envelope around this .

So if you are talking about passing TokerUSERID/Password in MM this will be passed in SOAP body.As per the screenshot it looks like you need to pass these in payload itself so yes you may use parameterized mapping.

For better understanding how the third party webservice accepts data i would suggest you to first try with soap ui there you can see whether token has to be passed in header or body then you may proceed your development accordingly.

Br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

I got xsd files and i am not sure how to include them in wsdl. I tried to import those 2 xsd's under external definitions and gave the local file path where it is saved in my computer to the wsdl source field. But didn't worked out.

Regards

PavanKumar
Active Contributor
0 Kudos

Hi Bhavana,

Import all xsd's separately as external definitions which is having reference with wsdl,

you can see the references of wsdls in external references tab of external definition.

Same reference url you need to place in source field of xsd which you imported seperately

So that xsd will be referenced to wsdl.

Regards

Pavan

former_member217029
Participant
0 Kudos

Hello Pavan,

Thanks for your reply. I did like below.

1) Imported 2 xsd's as external definitions, XSD Names are Request_Target.xsd & Response_Target.xsd

2) Imported wsdl as external definition. But i could not see anything under External References TAB. Does it mean that provided wsdl is wrong and not able to reference to corresponding xsd's?

From the imported wsdl file i could see these lines

<wsdl:types>

      <s:schema elementFormDefault="qualified" targetNamespace="https://www.xyz.com.br/WebServices/WebMethods">

         <s:element name="Execute">

            <s:complexType>

               <s:sequence>

                  <s:element minOccurs="0" maxOccurs="1" name="argDsComandoWSF">

                     <s:complexType>

                        <s:sequence>

                           <s:element ref="s:schema" />

                           <s:any />

                        </s:sequence>

                     </s:complexType>

                  </s:element>

               </s:sequence>

            </s:complexType>

         </s:element>

Is this Element ref="s:schema" should be replaced with xsd name in wsdl file?

manoj_khavatkopp
Active Contributor
0 Kudos

Check below link :

former_member217029
Participant
0 Kudos

Hello Manoj,

I did the same way that explained here but still i did not see any anything under references TAB of imported wsdl hence i am seeing fields in red.

I sent out email to webservice guy showing the issue and let's wait for their reply.

So in my case definitely i should have something under references TAB correct ?

Thanks

manoj_khavatkopp
Active Contributor
0 Kudos

Yes, and did u try putting the target url in browser and downloading the WSDL file ?

former_member217029
Participant
0 Kudos

Yes, I downloaded the wsdl from target URL and it's the same issue that i am not able to see anything under reference TAB.

Thanks

PavanKumar
Active Contributor
0 Kudos

Hi bhavana,

I think wsdl which you are importing is not proper it seems it should contain  xsds references in external references tab.

Regards

Pavan

former_member217029
Participant
0 Kudos

Hello Manoj,

When i open wsdl file in SOAP UI this is the request it is displayed. So based on this i understand that TokenUser & password should be passed as part of soap header and not body.

Planning to use mentioned UDF to convert whole Idoc to base64 and put it in argBase64 field . And Praveen Gandepalli's reply in this thread to add soap envelope.

Could you please suggest me how to proceed in this case? or can i pass TokenUser & Password directly in mapping?

<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:ReqData>

         <!--Optional:-->

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

         <!--Optional:-->

         <web:argStrEmissor>?</web:argStrEmissor>

      </web:ReqData>

   </soapenv:Body>

</soapenv:Envelope>

manoj_khavatkopp
Active Contributor
0 Kudos

Bhavana,

You can use OR xslt/jav mapping and build the soap envelope and pass userid and password.

br,

Manoj

former_member217029
Participant
0 Kudos

Hello Manoj,

Thank you.

while i am implementing below udf to convert whole Idoc to base64 encode and mappp to single field i am getting bellow error.

UDF:

public String Base64Encoding(String str, Container container) throws StreamTransformationException

{

try{

  byte[]   bytesEncoded = Base64.encode(str.getBytes("utf-8"));

  return new String(bytesEncoded );

} catch ( UnsupportedEncodingException e ) {

  return "Error";

}

I have included below imports. Am i missing any imports here? Do i need to import any packages into ESR to run ?

com.sap.aii.mapping.api.*

com.sap.aii.mapping.lookup.*

com.sap.aii.mappingtool.tf7.rt.*

java.io.*

java.lang.reflect.*

java.util.*

org.apache.xmlbeans.impl.util.Base64

java.security.*

Error:

manoj_khavatkopp
Active Contributor
0 Kudos

The error is because you have not imported the jar file into your mapping so make sure you have downloaded org.apache.xmlbeans.impl.util.Base64 and upload in ur mapping under Archive used.

Br,

Manoj

former_member217029
Participant
0 Kudos

Thank you Manoj. Yes you are correct. we have already this type of UDF in another interface so i have referred the same and it's working.

Thanks

Answers (0)