2

对于 PHP,我需要以下等效项

    System.Net.NetworkCredential credential = new System.Net.NetworkCredential("administrator", "PASSWORD", "DOMAIN");
    wsDynamicsGP.Credentials = credential;
    DynamicsGPWebService.Policy apPolicy = wsDynamicsGP.GetPolicyByOperation("CreatePayablesInvoice", context);

我正在传递域/用户密码

define('USERPWD', 'domain\username:password');

然后我发现了这个

class NTLMSoapClient extends SoapClient {
    function __doRequest($request, $location, $action, $version) {
        $headers = array(
            'Method: POST',
            'Connection: Keep-Alive',
            'User-Agent: PHP-SOAP-CURL',
            'Content-Type: text/xml; charset=utf-8',
            'SOAPAction: "'.$action.'"',
        );
        $this->__last_request_headers = $headers;
        $ch = curl_init($location);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POST, true );
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
        curl_setopt($ch, CURLOPT_USERPWD, USERPWD);
        $response = curl_exec($ch);
        return $response;
    }

    function __getLastRequestHeaders() {
        return implode("\n", $this->__last_request_headers)."\n";
    }
}

(有一个支持类,但我认为我不需要发布它)

所以为了测试我的连接,我正在这样做

// we unregister the current HTTP wrapper 
stream_wrapper_unregister('http');
// we register the new HTTP wrapper 
stream_wrapper_register('http', 'NTLMStream') or die("Failed to register protocol");

// Initialize Soap Client 
$baseURL = 'http://www.targetgpserver.com:port';
$client = new NTLMSoapClient($baseURL.'/DynamicsGPWebServices/DynamicsGPService.asmx?wsdl');
print_var($client);

当我运行脚本时,我得到以下信息:

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://erpweb.treecarescience.com:48620/DynamicsGPWebServices/DynamicsGPService.asmx' : Document is empty

有没有办法可以确认我可以使用类似 hurl.it 的东西进行连接?我不确定如何使用该服务处理域。

我在 Mac 上,还有其他方法可以确认我可以连接吗?

4

0 回答 0