无法成功执行SOAP API PHP调用(Silverpop)

时间:2019-04-09 05:49:17

标签: php soap schema

我正在尝试将SOAP API与IBM Watson Campaign Automation(Silverpop)一起使用-文档非常轻巧,我碰壁了。

我能够成功使用API​​登录,提取SessionID并使用它来创建SOAPHeader,但是当我尝试使用该SOAPHeader之后执行后续调用时,会收到错误消息“架构验证处理失败”。用户身份验证似乎可以正常工作,但是仍然缺少一些东西。

这是我要在PHP中转换的SOAP信封。请注意,这在我通过SOAPUI-5.5.0运行时当前有效:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sil="SilverpopApi:EngageService.SessionHeader" xmlns:sil1="SilverpopApi:EngageService.MailManagement.UserActions">
   <soapenv:Header>
      <sil:sessionHeader>
         <sil:sessionid>***</sil:sessionid>
      </sil:sessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <sil1:GetMailingTemplates>
         <sil1:VISIBILITY>1</sil1:VISIBILITY>
      </sil1:GetMailingTemplates>
   </soapenv:Body>
</soapenv:Envelope>

这是我的PHP文件的格式:

<?php

      $client = new SoapClient('http://api5.silverpop.com/SoapApi?wsdl', array('trace' => 1, 
             'encoding' => 'utf-8', 
             'content-type' => 'plain/xml'));

    $login = $client->Login(array('USERNAME'=>'***', 
                                  'PASSWORD'=>'***'));    

    $sessionID = $login->SESSIONID;

    echo 'The session ID is: '.$sessionID.'<br><br>';


    $namespace = 'SilverpopApi:EngageService.SessionHeader';
    $header = new SOAPHeader($namespace, 'sessionHeader', $sessionID);        
    $client->__setSoapHeaders($header);

    try {
       $getMailingTemplates = 
       $client->GetMailingTemplates(array('VISIBILITY'=>1));

     }
     catch (SoapFault $exception) {
        echo $exception->getMessage();    
     }
         var_dump($getMailingTemplates);


?>

这是我收到的带有SOAPUI信封的响应(不是PHP):

<envelope:Envelope xmlns:envelope="http://schemas.xmlsoap.org/soap/envelope/">
   <envelope:Header/>
   <envelope:Body xmlns="SilverpopApi:EngageService.MailManagement.UserActions">
      <RESULT>
         <SUCCESS>true</SUCCESS>
         <MAILING_TEMPLATE>
            <MAILING_ID>***</MAILING_ID>
            <MAILING_NAME>***</MAILING_NAME>
            <SUBJECT>***</SUBJECT>
            <LAST_MODIFIED>***</LAST_MODIFIED>
            <VISIBILITY>Shared</VISIBILITY>
            <USER_ID>***</USER_ID>
            <FLAGGED_FOR_BACKUP>false</FLAGGED_FOR_BACKUP>
         </MAILING_TEMPLATE>
[... repeated for all templates]

这是我通过PHP调用收到的响应:

"The session ID is: ***

Schema Validation processing failed"

我知道来自PHP调用的sessionID格式正确,因为我可以将其插入SOAPUI,并且可以正常工作。我感觉好像SOAPHeader函数可能缺少某些内容,也许与名称空间有关,但是我尝试过的那些参数的任何变体都没有用。希望这个问题不是Silverpop所特有的,具有更多PHP / SOAP经验的人可以帮助您识别代码中的任何空白。

0 个答案:

没有答案
相关问题