Re: using targetWorkspace in the SOAP API with PHP helper

Anonymous
Not applicable

using targetWorkspace in the SOAP API with PHP helper

Is there more info on using the contextHeader in the API? 

It is listed in the WSDL:
http://app.marketo.com/soap/mktows/2_0?WSDL 

but I do not see anything about the context header in the marketo_api.php file.

When looking at the docs, I can't find too many specifics on using the contextHeader other than syncLead is the only API call that supports it.  Is it an additional parameter passed into the syncLead API call? 

thx!
Tags (1)
5 REPLIES 5
Anonymous
Not applicable

Re: using targetWorkspace in the SOAP API with PHP helper

targetWorkspace will be "Default" if the instance does not have workspaces enabled otherwise you can select one the existing workspaces, including Default.
Anonymous
Not applicable

Re: using targetWorkspace in the SOAP API with PHP helper

Can you provide an example of using the contextHeader in XML? 

Unless I'm missing something, it does not appear to be on the syncLead page for XML or PHP but is for JAVA
http://developers.marketo.com/documentation/soap/synclead/ 

thx!

Anonymous
Not applicable

Re: using targetWorkspace in the SOAP API with PHP helper

Java
 
MktowsContextHeader headerContext = new MktowsContextHeader();
headerContext.setTargetWorkspace("default");


XML - complete call skeleton

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
   <soapenv:Header>
      <mkt:MktowsContextHeader>
         <targetWorkspace>?</targetWorkspace>
      </mkt:MktowsContextHeader>
      <mkt:AuthenticationHeader>
         <mktowsUserId>?</mktowsUserId>
         <requestSignature>?</requestSignature>
         <requestTimestamp>?</requestTimestamp>
         <!--Optional:-->
         <audit>?</audit>
         <!--Optional:-->
         <mode>?</mode>
      </mkt:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mkt:paramsSyncLead>
         <leadRecord>
            <!--Optional:-->
            <Id>?</Id>
            <!--Optional:-->
            <Email>?</Email>
            <!--Optional:-->
            <ForeignSysPersonId>?</ForeignSysPersonId>
            <!--Optional:-->
            <ForeignSysType>?</ForeignSysType>
            <!--Optional:-->
            <leadAttributeList>
               <!--Zero or more repetitions:-->
               <attribute>
                  <attrName>?</attrName>
                  <!--Optional:-->
                  <attrType>?</attrType>
                  <attrValue>?</attrValue>
               </attribute>
            </leadAttributeList>
         </leadRecord>
         <returnLead>?</returnLead>
         <!--Optional:-->
         <marketoCookie>?</marketoCookie>
      </mkt:paramsSyncLead>
   </soapenv:Body>
</soapenv:Envelope>

Anonymous
Not applicable

Re: using targetWorkspace in the SOAP API with PHP helper

bgomes,

We were able to solve this by modifying the sample code. I would suggest you add this to the sample code so others don't have to figure out something that has already been figured out.

For those who run into this issue, you can get passed this by modifying the sample code like we did.

        //Create SOAP Header
        $attrs = new stdClass();
        $attrs->mktowsUserId = $this->accessKey;
        $attrs->requestSignature = $signature;
        $attrs->requestTimestamp = $timestamp;
        $context = new stdClass();
        $context->targetWorkspace = $workspace;
        $soapHdr = array();
        $soapHdr[] = new SoapHeader(self::MKTOWS_NAMESPACE, 'MktowsContextHeader', $context);
        $soapHdr[] = new SoapHeader(self::MKTOWS_NAMESPACE, 'AuthenticationHeader', $attrs);


        //Create Soap Client and Set Headers
        $soapClient = new SoapClient($marketoSoapEndPoint ."?WSDL", $options);
        $soapClient->__setSoapHeaders($soapHdr);
        try {
              $result = $soapClient->__soapCall('syncLead', $params, $options);
        } catch(Exception $ex) {
             var_dump($ex);
        }

Anonymous
Not applicable

Re: using targetWorkspace in the SOAP API with PHP helper

Is syncLead the only API call that supports setting the target workspace? What do you do if you need to pass a batch of leads into a specific workspace?