how Can I authenticate through marketo soap api?

Anonymous
Not applicable

how Can I authenticate through marketo soap api?

hi

I am converting wsdl to java using following wsdl

 

https://074-UIN-407.mktoapi.com/soap/mktows/2_1?WSDL

Adding jar created of the java classes in my project. 

I am trying to call listMObject(ParamsListMObjects) method. However I am getting following exception

20012 - Request not understood    

Request does appear to conform to WSDL (20012)

I am not having any idea why I am getting that is it because of not authenticating? if yes then how I can authenticate it? and ParamsListMObjects  I am just creating object of this and passing to listMObject.

Thanks

Tags (1)
4 REPLIES 4
Anonymous
Not applicable

Re: how Can I authenticate through marketo soap api?

From your post " am just creating object of this and passing to listMObject." it is relatively safe to assume the API call is failing because there is no authentication in place.
 
 
The generic XML call for listMObject is :
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
   <soapenv:Header>
      <mkt:AuthenticationHeader>
         <mktowsUserId>?</mktowsUserId>
         <requestSignature>?</requestSignature>
         <requestTimestamp>?</requestTimestamp>
         <!--Optional:-->
         <audit>?</audit>
         <!--Optional:-->
         <mode>?</mode>
      </mkt:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mkt:paramsListMObjects/>
   </soapenv:Body>
</soapenv:Envelope>
 
(you may need to use a code formatter as the editor will remove all indentation).
 
 
You musr authienticate all SOAP API calls.
Admin - SOAP API displays the User ID and Encryption key.
From that information you will obtain the requestSignature and requestTimestamp.
 
requestTimestamp lasts for 15 minutes, more than sufficient for an API call.
A new API call needs to recalculate requestSignature and requestTimestamp.
 
 
You can use the SOAP API PHP client or Java to learn how to calculate those values even though you may be using a completely different programming language. You just need to port to your programming language of choice.
 
Marketo SOAP API PHP client
 
Marketo SOAP API Java example
 

Anonymous
Not applicable

Re: how Can I authenticate through marketo soap api?

Hi bgomes

    Thanks for your reply.

 I tried java example

https://community.marketo.com/MarketoArticle?id=kA050000000KzVNCA0

however when I am trying to call listMObject from example it have two parameters 1. params 2. authentication header

listMObject(ParamsListMObjects,AuthenticationHeader)   

whereas if I create java classes from wsdl  https://074-UIN-407.mktoapi.com/soap/mktows/2_1?WSDL

then listMObject have only one parameter listMObject(ParamsListMObjects)  so where I can  pass authentication header info if I want to use above wsdl?

Anonymous
Not applicable

Re: how Can I authenticate through marketo soap api?

Hi bgomes

 

              I am able to set authentication header.  Following code I have written

MktowsApiSoapBindingStub stub = (MktowsApiSoapBindingStub) _port;
 
// Clear the headers to make sure you know exactly what you are sending.
// Headers do not overwrite when you are using Axis/Java
stub.clearHeaders();
 
SOAPHeaderElement userAuthenticationHeader = new SOAPHeaderElement(  new QName("http://www.marketo.com/mktows/", "AuthenticationHeader")   );
 
AuthenticationHeaderInfo authentication = null;
try {
 
authentication =  createAuthenticationHeader();
 
} catch (MktowsClientException e) {
e.printStackTrace();
}
 
userAuthenticationHeader.setObjectValue(authentication);
stub.setHeader(userAuthenticationHeader);

In createAuthenticationHeader() I have added signature and timestamp to the method.
Anonymous
Not applicable

Re: how Can I authenticate through marketo soap api?

Shrikant/Anil,
Please try regenerating the Java classes using this command -

wsimport -XadditionalHeaders -b binding2.xml -p com.marketo.mktows.wsdl -s src -d bin http://<your URL>/soap/mktows/2_1?WSDL

I believe this should help you overcome the issue 

Raj