首页 > 解决方案 > 如何参数化 PHP Soap 调用 - Taleo

问题描述

我需要从 Taleo WS 获取实体列表。我有一个工作肥皂 xml 示例,但我不知道如何参数化 php soap 调用。谁能给我一个提示?

请求如下

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:find="http://www.taleo.com/ws/tee800/2009/01/find">
   <soapenv:Header/>
   <soapenv:Body>
      <find:findPartialEntities>
         <find:mappingVersion>http://www.taleo.com/ws/tee800/2009/01</find:mappingVersion>
         <find:query>
            <query:query alias="Find Open and Posted Requisitions" projectedClass="SourcingRequest" xmlns:query="http://itk.taleo.com/ws/query">
               <query:projections>
                  <query:projection>
                     <query:field  path="Requisition,ContestNumber"/>
                  </query:projection>
                  <query:projection>
                    <query:field locales="it" path="Requisition,JobInformation,Title" localeFiltering="customLocales"/>
                  </query:projection>
                  <query:projection>
                     <query:field locales = "it" path="Requisition,JobInformation,DescriptionExternalHTML" localeFiltering="customLocales"/>
                  </query:projection>
                   <query:projection>
                     <query:field locales = "it" path="Requisition,JobInformation,DescriptionInternalHTML" localeFiltering="customLocales"/>
                  </query:projection>
                  <query:projection>
                     <query:field path="Requisition,Number"/>
                  </query:projection>
                  <query:projection>
                     <query:field path="Requisition,State,Description"/>
                  </query:projection>
                  <query:projection>
                     <query:field locales="it" path="Requisition,JobInformation,JobField,Name" localeFiltering="customLocales"/>
                  </query:projection>
                  <query:projection>
                     <query:field locales="it" path="Requisition,JobInformation,Organization,Name" localeFiltering="customLocales"/>
                  </query:projection>
                  <query:projection>
                     <query:field locales="it" path="Requisition,JobInformation,Location,PrimaryLocation,Name" localeFiltering="customLocales"/>
                  </query:projection>
                  <query:projection>
                     <query:field locales="it" path="SourcingRequestStatus,Description" localeFiltering="customLocales"/>
                  </query:projection>
               </query:projections>
               <query:filterings>
                  <query:filtering>
                     <query:equal>
                        <query:field locales="it" path="SourcingRequestStatus,Description" localeFiltering="customLocales"/>
                        <query:string>Pubblicata</query:string>
                     </query:equal>
                  </query:filtering>
               </query:filterings>
               <query:sortings>
                  <query:sorting>
                     <query:field path="Requisition,ContestNumber"/>
                  </query:sorting>
               </query:sortings>
            </query:query>
         </find:query>
         <find:attributes/>
      </find:findPartialEntities>
   </soapenv:Body>
</soapenv:Envelope>

到目前为止,我制作了这段代码

$wsdlUrl = 'https://s01iit.taleo.net/enterprise/soap?ServiceName=FindService&wsdl';

$options = array(
  'login' => 'myUsername',
  'password' => 'myPassword'
);
        
        
try {
    $client = new SoapClient($wsdlUrl, $options);
    
    $params = array(
                    "mappingVersion"=>"http://www.taleo.com/ws/tee800/2009/01",
                    "query" => "",
                    "attributes" => ""
                    );	
       
		$result = $client->findPartialEntities($params);
		
    die(var_dump($result));

我收到“没有为操作接收到足够的消息部分”。错误作为响应。

谢谢

标签: phpweb-servicessoapwsdltaleo

解决方案


它有点棘手,因为 taleo soap 文档很差。我花了几天时间调查它,还有很多事情要做。这是一个可以提供帮助的基本示例:

$query = [
  'query' => [
    'projectedClass' => "Requisition",
    'alias' => "Find Open and Posted Requisitions a",
    'subQueries' => '',
    'projections' => [
      'projection' => [
        'field' => [
          'path' => 'JobInformation,Title'
        ]
      ]
    ]

  ]
];

$attributes = [
  "entry" => [
    ['key' => 'pageindex', 'value' => '1'],
    ['key' => 'pagingsize', 'value' => '10']
  ]
];


try {
  $client = new SoapClient($findServiceWSDL, $options);
  $arguments = array('mappingVersion' => 'http://www.taleo.com/ws/art750/2006/12', 'query' => $query, 'attributes' => $attributes);
} catch (Exception $e) {

  echo $e->getMessage();
  echo '<br>';
  echo $e->getTraceAsString();
  echo htmlentities($client->__getLastRequest());
  echo '<br><br><br>';
  echo htmlentities($client->__getLastResponse());
}

我希望这能帮到您。


推荐阅读