jvo*_*jvo 17 php soap wsdl web-services dynamics-crm-2011
我必须通过Web服务访问crm 2011中的潜在客户(创建新的潜在客户并获取列表).我已经在c#/ asp.net中创建了一个应用程序(它可以工作),但现在我必须在php中完成它并且我被卡住了.
我尝试:https://code.google.com/p/php-dynamics-crm-2011/,但它不起作用,因为它只支持联合身份验证并挖掘它的活动目录.
我尝试与nusoap连接,但这非常令人困惑.
我使用wsdl2php生成发现服务和组织服务类:http://www.urdalen.no/wsdl2php/ 但我不知道如何处理这些类.
有人举例说明如何使用这些类?
MSCRM 2013和2011年可能正在使用NTLM对web服务进行身份验证.
对于数据查询,您可以使用url编码的FetchXML
http://msdn.microsoft.com/en-us/library/gg328117.aspx
您可以通过在高级搜索中导出XML并使用RetrieveMultiple方法执行查询来从CRM获取正确的XML.
我正在添加一个SOAP信封和CURL POST查询示例,并使用NTLM进行身份验证.
<?php
$soap_envelope = <<<END
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<query i:type="a:FetchExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:Query><fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='contact'>
<attribute name='fullname' />
<attribute name='parentcustomerid' />
<attribute name='telephone1' />
<attribute name='emailaddress1' />
<attribute name='contactid' />
<order attribute='fullname' descending='false' />
<filter type='and'>
<condition attribute='ownerid' operator='eq-userid' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
</entity>
</fetch></a:Query>
</query>
</RetrieveMultiple>
</s:Body>
</s:Envelope>
END;
$soap_action = 'http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/RetrieveMultiple';
$req_location = 'http://crm.server.local/YourOrganization/XRMServices/2011/Organization.svc/web';
$headers = array(
'Method: POST',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "'.$soap_action.'"'
);
$user = 'YOURDOMAIN\YOURUSERNAME';
$password = '**********';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $req_location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_envelope);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
$response = curl_exec($ch);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
var_dump($response);
}
Run Code Online (Sandbox Code Playgroud)