目前,我正在尝试将PHP网站与MS Dynamics 2013连接起来。我发现以下示例(https://github.com/rocketeer007/php-dynamics-crm-2011)要连接但它无法正常工作。
我提供了配置但是出现了以下错误,即
string(576) "http://www.w3.org/2005/08/addressing/soap/faults:Sendera:InvalidSecurity
An error occurred when verifying security for the message."
我无法找到有关肥皂反应的更多信息。
以下是我在请求中发送的更多信息,即
**NOTE: For example purposes below I have changed the URLs**
//Parameters values used in the below CURL
$soapUrl = https://example.crmserver.com/adfs/services/trust/13/usernamemixed
$headers = 'POST /adfs/services/trust/13/usernamemixed HTTP/1.1
Host: adfs.crmserver.com
Connection: Keep-Alive
Content-type: application/soap+xml; charset=UTF-8
Content-length: 1481'
$content = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://adfs.crmserver.co.nz/adfs/services/trust/13/usernamemixed</a:To>
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
<u:Timestamp u:Id="_0">
<u:Created>2015-07-16T04:09:52.00Z</u:Created>
<u:Expires>2015-07-16T04:10:52.00Z</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="user">
<o:Username>desktop\abc_service.mrl</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<trust:RequestSecurityToken xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>https://dev2013.crm.crmserver.co.nz/XRMServices/2011/Discovery.svc</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType>
</trust:RequestSecurityToken>
</s:Body>
// Request
$cURLHandle = curl_init();
curl_setopt($cURLHandle, CURLOPT_URL, $soapUrl);
curl_setopt($cURLHandle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($cURLHandle, CURLOPT_TIMEOUT, self::$connectorTimeout);
curl_setopt($cURLHandle, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($cURLHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
curl_setopt($cURLHandle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($cURLHandle, CURLOPT_POST, 1);
curl_setopt($cURLHandle, CURLOPT_POSTFIELDS, $content);
curl_setopt($cURLHandle, CURLOPT_HEADER, false);
curl_setopt($cURLHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
$responseXML = curl_exec($cURLHandle);
if(curl_exec($cURLHandle) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo "no error <br />";
var_dump($responseXML);
}
我试图看到错误,但得到以下即 没有错误
我在互联网上陷入困境并进行研究,因此无法找到任何内容,因此在这里张贴......
更多信息: 当我从命令行尝试这个时,即 卷曲-H&#34;授权:持票人&#34; https://dev2013.crm.example.com/XRMServices/2011/Discovery.svc -v
然后,我得到了以下输出,即
About to connect() to dev2013.crm.appserv.co.nz port 443 (#0)
* Trying x.x.x.x... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES128-SHA
* Server certificate:
* subject: C=AU; ST=Sydney; L=Sydney; O=Example Ltd; CN=*.crm.example.com
* start date: 2015-06-24 00:00:00 GMT
* expire date: 2017-08-22 23:59:59 GMT
* subjectAltName: dev2013.crm.example.com matched
* issuer: C=US; O=thawte, Inc.; CN=thawte SSL CA - G2
* SSL certificate verify ok.
> GET /XRMServices/2011/Discovery.svc HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: dev2013.crm.example.com
> Accept: */*
> Authorization: Bearer
>
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Set-Cookie: ISAWPLB{11FDD9E3-24F0-455D-8590-436AF3F4D26D}={B0F3D377-6B32-45C6-A517-DA83209E8EA4}; HttpOnly; Path=/
< Content-Length: 3127
< Date: Thu, 16 Jul 2015 03:26:39 GMT
< Content-Type: text/html; charset=UTF-8
< Server: Microsoft-IIS/8.5
< Cache-Control: private
< X-AspNet-Version: 4.0.30319
< REQ_ID: 5b87d8d2-8b5e-4979-b090-7df14a3a1603
< Set-Cookie: ReqClientId=751fb9c2-ac10-478a-b933-2117420c660c; expires=Thu, 16-Jul-2065 03:26:39 GMT; path=/; secure; HttpOnly
< X-Powered-By: ASP.NET
这意味着使用上述发现服务器连接到CRM没有问题。
寻找有关错误的即时帮助以及使用PHP SOAP Web服务从CRM获取身份验证的最佳建议。
提前致谢。
干杯,
答案 0 :(得分:0)
Jason Lattimer有一个使用IFD的更新示例。
http://jlattimer.blogspot.com.au/2015/02/soap-only-authentication-using-php.html
乍看之下似乎有一些差异。 首先,您没有消息ID(应该在行动线下)
<a:MessageID>urn:uuid:{A RANDOM GUID GOES HERE}</a:MessageID>
其次你有以下一行
<o:UsernameToken u:Id="user">
我认为应该是GUID
<o:UsernameToken u:Id="{GUID GOES HERE}">
最后,您看起来像是指向发现服务,我认为您应该指向组织服务。
Organization.svc
我自己还没有做任何PHP-IFD的事情,所以我建议去Jason的博客并与你的博客进行比较。
答案 1 :(得分:0)
我更正了DEV服务器上的时间,然后解决了身份验证问题。
感谢大家花时间阅读这个问题。