简体   繁体   English

PHP SOAP与MS Dynamics 2011/2013(IFD)的集成

[英]PHP SOAP Integration with MS Dynamics 2011/2013 (IFD)

Currently, I am trying to connect PHP website with MS Dynamics 2013. I found the following example ( https://github.com/rocketeer007/php-dynamics-crm-2011 ) to connect to but it is not working. 当前,我正在尝试将PHP网站与MS Dynamics 2013连接起来。我发现以下示例( https://github.com/rocketeer007/php-dynamics-crm-2011 )可连接,但无法正常工作。

I provided the configuration but is getting following error ie 我提供了配置,但出现以下错误,即

string(576) "http://www.w3.org/2005/08/addressing/soap/faults:Sendera:InvalidSecurity 
An error occurred when verifying security for the message."

I couldn't find more information about the soap response. 我找不到有关肥皂反应的更多信息。

Here is the more information that I am sending in my request ie 这是我在请求中发送的更多信息,即

     **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);
    }

I tried to see the error but get following ie no error 我试图看到错误,但得到关注,即没有错误

I am stuck and researched over the internet and couldn't find anything on it therefore, is posting over here... 我被困在互联网上并进行了研究,因此找不到任何内容,因此发布在这里...

More Information: When I tried this from command line ie curl -H "Authorization: Bearer" https://dev2013.crm.example.com/XRMServices/2011/Discovery.svc -v 更多信息:当我从命令行尝试此操作时,即curl -H“ Authorization:Bearer” https://dev2013.crm.example.com/XRMServices/2011/Discovery.svc -v

Then, I got the following output ie 然后,我得到以下输出,即

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

It means that there is no issue with connecting to CRM using the above discovery server. 这意味着使用上述发现服务器连接到CRM没有问题。

Looking for instant help on the error and the best recommendation to get authentication from the CRM using PHP SOAP webservices. 寻找有关错误的即时帮助以及关于使用PHP SOAP Web服务从CRM获得身份验证的最佳建议。

Thanks in advance. 提前致谢。

Cheers, 干杯,

Jason Lattimer has an updated example using IFD. Jason Lattimer有一个使用IFD的更新示例。

http://jlattimer.blogspot.com.au/2015/02/soap-only-authentication-using-php.html http://jlattimer.blogspot.com.au/2015/02/soap-only-authentication-using-php.html

At a glance there seems to be a few discrepancies. 乍一看似乎有一些差异。 Firstly you don't have a message ID (Should be just under the action line) 首先,您没有消息ID(应该在操作行下方)

<a:MessageID>urn:uuid:{A RANDOM GUID GOES HERE}</a:MessageID>

Secondly you have the following line 其次,您有以下一行

<o:UsernameToken u:Id="user">

Which I walso believe should be a GUID 我也认为应该是GUID

<o:UsernameToken u:Id="{GUID GOES HERE}">

Finally you look like you're pointing to the Discovery Service where I think you should be pointing to the organisation service. 最后,您看起来好像要指向发现服务,而我认为您应该指向组织服务。

Organization.svc Organization.svc

I haven't done any PHP-IFD stuff myself so I'd suggest going to Jason's blog and comparing it with yours. 我自己还没有做过PHP-IFD的工作,因此建议您访问Jason的博客并将其与您的博客进行比较。

Campey, thanks for your time. 坎佩,谢谢您的时间。 Both DEV and LIVE Servers are in the same timezone the only difference that I have found the DEV server timezone is 10 minutes behind from the LIVE server. DEV和LIVE服务器都处于同一时区,唯一的区别是我发现DEV服务器时区比LIVE服务器晚10分钟。

I corrected the time on DEV server and then the authentication problem is solved. 我更正了DEV服务器上的时间,然后解决了身份验证问题。

Thanks everyone for investing time to read the issue. 感谢大家花时间阅读该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM