肥皂php Microsoft Dynamics crm online 2011

时间:2013-02-22 09:21:20

标签: php soap dynamics-crm-2011 dynamics-crm nusoap

我在使用nusoap与microsoft dynamics crm online 2011交谈时遇到错误。 这是一些调试信息

 Error: wsdl error: Getting https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0 - HTTP ERROR: no proper separation of headers and document

Debug

2013-02-22 09:13:58.670652 nusoap_client: ctor wsdl=wsdl timeout=0 response_timeout=30
endpoint=string(16) "organization.xml"
2013-02-22 09:13:58.676050 nusoap_client: will use lazy evaluation of wsdl from organization.xml
2013-02-22 09:13:58.676090 nusoap_client: setCredentials username=testserver2013.onmicrosoft.com\matthewhudghton authtype=ntlm certRequest=
array(0) {
}
2013-02-22 09:13:58.676141 nusoap_client: setUseCURL(1)
2013-02-22 09:13:58.676169 nusoap_client: useHTTPPersistentConnection
2013-02-22 09:13:58.676367 nusoap_client: call: operation=Create, namespace=http://schemas.microsoft.com/crm/2007/WebServices, soapAction=http://schemas.microsoft.com/crm/2007/WebServices/Create, rpcParams=, style=rpc, use=encoded, endpointType=wsdl
params=string(223) "<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"></soap:Envelope>"
headers=array(3) {
  ["SOAPAction"]=>
  string(56) "http://schemas.microsoft.com/crm/2007/WebServices/Create"
  ["Content-Type"]=>
  string(23) "text/xml; charset=utf-8"
  ["Content-Length"]=>
  int(1095)
}
2013-02-22 09:13:58.676435 nusoap_client: instantiating wsdl class with doc: organization.xml
2013-02-22 09:13:58.676539 wsdl: ctor wsdl= timeout=0 response_timeout=30
2013-02-22 09:13:58.676578 wsdl: parse and process WSDL path=
2013-02-22 09:13:58.676632 wsdl: setCredentials username=testserver2013.onmicrosoft.com\matthewhudghton authtype=ntlm certRequest=
array(0) {
}
2013-02-22 09:13:58.676679 wsdl: parse and process WSDL path=organization.xml
2013-02-22 09:13:58.676713 wsdl: parse WSDL at path=organization.xml
2013-02-22 09:13:58.676785 wsdl: getting WSDL file organization.xml
2013-02-22 09:13:58.693021 wsdl: Parse WSDL
2013-02-22 09:13:58.708375 wsdl: parsing import http://schemas.microsoft.com/xrm/2011/Contracts/Services - https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0 (1)
2013-02-22 09:13:58.708615 wsdl: current service: OrganizationService
2013-02-22 09:13:58.708834 wsdl: current port: CustomBinding_IOrganizationService
2013-02-22 09:13:58.709290 wsdl: Parsing WSDL done
2013-02-22 09:13:58.709414 wsdl: parse WSDL at path=https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0
2013-02-22 09:13:58.709482 wsdl: getting WSDL http(s) URL https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0
2013-02-22 09:13:58.709646 soap_transport_http: ctor url=https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0 use_curl=1 curl_options:
array(0) {
}
2013-02-22 09:13:58.709750 soap_transport_http: parsed URL scheme = https
2013-02-22 09:13:58.709814 soap_transport_http: parsed URL host = testserver2013.api.crm4.dynamics.com
2013-02-22 09:13:58.709865 soap_transport_http: parsed URL path = /XRMServices/2011/Organization.svc
2013-02-22 09:13:58.709916 soap_transport_http: parsed URL query = wsdl=wsdl0
2013-02-22 09:13:58.709984 soap_transport_http: set header Host: testserver2013.api.crm4.dynamics.com
2013-02-22 09:13:58.710126 soap_transport_http: set header User-Agent: NuSOAP/0.9.5 (1.123)
2013-02-22 09:13:58.710205 soap_transport_http: setCredentials username=testserver2013.onmicrosoft.com\matthewhudghton authtype=ntlm digestRequest=
array(0) {
}
2013-02-22 09:13:58.710270 soap_transport_http: certRequest=
array(0) {
}
2013-02-22 09:13:58.710334 soap_transport_http: Authorization header not set for ntlm
2013-02-22 09:13:58.710398 soap_transport_http: set header Accept-Encoding: gzip, deflate
2013-02-22 09:13:58.710452 soap_transport_http: set header Connection: close
2013-02-22 09:13:58.710512 soap_transport_http: entered send() with data of length: 0
2013-02-22 09:13:58.710583 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme https, host testserver2013.api.crm4.dynamics.com, port 443
2013-02-22 09:13:58.710662 soap_transport_http: connect using cURL
2013-02-22 09:13:58.750685 soap_transport_http: setCurlOption option=10002, value=
string(93) "https://testserver2013.api.crm4.dynamics.com:443/XRMServices/2011/Organization.svc?wsdl=wsdl0"
2013-02-22 09:13:58.750843 soap_transport_http: setCurlOption option=52, value=
int(1)
2013-02-22 09:13:58.750920 soap_transport_http: setCurlOption option=42, value=
int(1)
2013-02-22 09:13:58.750993 soap_transport_http: setCurlOption option=19913, value=
int(1)
2013-02-22 09:13:58.751065 soap_transport_http: setCurlOption option=13, value=
int(30)
2013-02-22 09:13:58.751133 soap_transport_http: set cURL SSL verify options
2013-02-22 09:13:58.751186 soap_transport_http: setCurlOption option=64, value=
int(0)
2013-02-22 09:13:58.751255 soap_transport_http: setCurlOption option=81, value=
int(0)
2013-02-22 09:13:58.751326 soap_transport_http: set cURL username/password
2013-02-22 09:13:58.751385 soap_transport_http: setCurlOption option=10005, value=
string(62) "testserver2013.onmicrosoft.com\matthewhudghton:fakepassword"
2013-02-22 09:13:58.751519 soap_transport_http: set cURL for NTLM authentication
2013-02-22 09:13:58.751574 soap_transport_http: setCurlOption option=107, value=
int(8)
2013-02-22 09:13:58.751644 soap_transport_http: cURL connection set up
2013-02-22 09:13:58.751721 soap_transport_http: HTTP request: GET /XRMServices/2011/Organization.svc?wsdl=wsdl0 HTTP/1.1
2013-02-22 09:13:58.751791 soap_transport_http: HTTP header: Host: testserver2013.api.crm4.dynamics.com
2013-02-22 09:13:58.751845 soap_transport_http: HTTP header: User-Agent: NuSOAP/0.9.5 (1.123)
2013-02-22 09:13:58.751897 soap_transport_http: HTTP header: Accept-Encoding: gzip, deflate
2013-02-22 09:13:58.751950 soap_transport_http: HTTP header: Connection: close
2013-02-22 09:13:58.752017 soap_transport_http: Skip cURL header Host: testserver2013.api.crm4.dynamics.com
2013-02-22 09:13:58.752091 soap_transport_http: Skip cURL header Connection: close
2013-02-22 09:13:58.752145 soap_transport_http: setCurlOption option=10023, value=
array(2) {
  [0]=>
  string(32) "User-Agent: NuSOAP/0.9.5 (1.123)"
  [1]=>
  string(30) "Accept-Encoding: gzip, deflate"
}
2013-02-22 09:13:58.752243 soap_transport_http: set cURL HTTP headers
2013-02-22 09:13:58.752369 soap_transport_http: set cURL payload
2013-02-22 09:13:58.752444 soap_transport_http: send and receive with cURL
2013-02-22 09:14:09.725981 soap_transport_http: No cURL error, closing cURL
2013-02-22 09:14:09.726600 soap_transport_http: Found HTTP header to skip
2013-02-22 09:14:09.726673 soap_transport_http: Found HTTP header to skip
2013-02-22 09:14:09.726727 soap_transport_http: no proper separation of headers and document
2013-02-22 09:14:09.726758 soap_transport_http: end of send()
2013-02-22 09:14:09.726804 wsdl: Getting https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0 - HTTP ERROR: no proper separation of headers and document
2013-02-22 09:14:09.726898 nusoap_client: checkWSDL
2013-02-22 09:14:09.726932 nusoap_client: got wsdl error: Getting https://testserver2013.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0 - HTTP ERROR: no proper separation of headers and document
string(0) ""

这是我目前的代码:

   <?php
require_once('lib/nusoap.php');

$login ='testserver2013.onmicrosoft.com\matthewhudghton'; // crm login name 
$pass ='fakepassword';
$useCURL = 1;

$client = new nusoap_client("organization.xml", 'wsdl');
$client->setCredentials($login, $pass, 'ntlm');
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
$client->setUseCurl($useCURL);
$client->useHTTPPersistentConnection();

// Prepare values for the new contact.
$firstname = "112";
$lastname = "123";
$donotbulkemail = "true";
$address1_stateorprovince = "MT";
$address1_postalcode = "99999";
$address1_line1 = "23 Market St.";
$address1_city = "Sammamish";

// This exact header was recieved from GenerateAuthenticationHeader() JScript function.
$authenticationHeader = '<soap:Header><CrmAuthenticationToken xmlns=“http://schemas.microsoft.com/crm/2007/WebServices“><AuthenticationType xmlns=“http://schemas.microsoft.com/crm/2007/CoreTypes“>1</AuthenticationType><OrganizationName xmlns=“http://schemas.microsoft.com/crm/2007/CoreTypes“>personal</OrganizationName><CallerId xmlns=“http://schemas.microsoft.com/crm/2007/CoreTypes“>00000000-0000-0000-0000-000000000000</CallerId></CrmAuthenticationToken></soap:Header>';

// Prepare the SOAP message.
$xml = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" .  $authenticationHeader . "<soap:Body><Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'><entity xsi:type='contact'><address1_city>" . $address1_city . "</address1_city>" .  "<address1_line1>" . $address1_line1 . "</address1_line1>" .  "<address1_postalcode>" . $address1_postalcode . "</address1_postalcode>" .  "<address1_stateorprovince>" . $address1_stateorprovince . "</address1_stateorprovince>" .  "<donotbulkemail>" . $donotbulkemail . "</donotbulkemail>" .  "<firstname>" . $firstname . "</firstname>" .  "<lastname>" . $lastname . "</lastname>" .  "</entity>" .  "</Create>" .  "</soap:Body>" .  "</soap:Envelope>";

$headers = array('SOAPAction' => 'http://schemas.microsoft.com/crm/2007/WebServices/Create', 'Content-Type' => 'text/xml; charset=utf-8', 'Content-Length' => strlen($xml));



$xml = '<?xml version="1.0" encoding="utf-8"?>' .
    '<soap:Envelope' .          
        ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' .
        ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' .
        ' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' .
    $soapHeader .
    $soapBody .
    '</soap:Envelope>';

//SOAP call
$result = $client->call('Create', $xml, 'http://schemas.microsoft.com/crm/2007/WebServices', 'http://schemas.microsoft.com/crm/2007/WebServices/Create', $headers);


if ($client->fault) {
    echo '<p><b>Fault: ';
    print_r($result);
    echo '</b></p>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<p><b>Error: ' . $err . '</b></p>';
        echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    } else {
        // Display the result
        print_r($result);
    }
}

var_dump($client->response);    

?>

任何想法?不确定“HTTP错误:没有正确分离标题和文档”但感觉可能只是因为它因某些原因无法进行身份验证。 我的用户名是否格式正确? 感谢

0 个答案:

没有答案