Problem Fetching Data

Dec 12, 2012 at 7:34 PM

Hi, I'm really, really new to OData and the company I'm working on is Migrating their Quickbooks environment to NAV and I need to fetch data on the web using OData.

I'm my testing environment I'm using Win 7 IIS7 Web Server and PHP, I already installed the OData SDK into the environment and is running fine but I get this:

QueryOperationResponse Object
(
    [_headers:protected] => Array
        (
        )

    [_innerException:protected] => Error occured during request for http://[SERVER]:[PORT]/[COMPANY]/Odata/Customers?$filter=CustomerID+eq+'C0001': Received HTTP code 400 from proxy after CONNECT

    [_statusCode:protected] => 404
    [_query:protected] => http://[SERVER]:[PORT]/[COMPANY]/Odata/Customers?$filter=CustomerID+eq+'C0001'
    [Result] => 
    [CountValue] => 
    [ObjectIDToNextLinkUrl] => Array
        (
        )

)

When I link directly to the page requested I see the data of Customer C0001 but for any reason when I have it run through the SDK return that error.

I'm assuming is the proxy, but I just follow the same procedure from the Netflix sample, set up a app.config.ini file and put the proxy info in there. I echo the $proxy->HttpProxy and all the value are correct but still have this error.

Is there's something I'm missing?

Is there's a configuration file I need to create first?

Any advice will be greatly appreciate. Thanks

Dec 14, 2012 at 5:42 PM

OK, I found the error and it quite simple:

In the ObjectContext.php I went to the _construct function and change the value of $this->Credential from null to:

$this->Credential = new WindowsCredential("your\user","yourpassword");

And remove the proxy. Was not aware that NAV Server does not allow proxy authentication. So the __construct function should look like:

/**
     * Constructs a new ObjectContext object.
     *
     * @param string $uri
     */
    public function __construct($uri)
    {
        $this->ObjectToResource = new Dictionary();
        $this->Bindings = new Dictionary();
        $this->IdentityToResource = array();
        $this->_nextChange = 0;
        $this->Credential = new WindowsCredential('domain\username','password');
        $this->HttpProxy = null;
        $this->_onBefore_cb_instance = null;
        $this->_onBefore_cb_function = null;
        $this->_onAfter_cb_instance = null;
        $this->_onAfter_cb_function = null;
        $this->_baseURI = $uri;
        $this->_baseUriWithSlash = $this->_baseURI;
        $this->CustomHeaders = array();
        if($this->_baseUriWithSlash[(strlen($this->_baseUriWithSlash) - 1)] != '/')
        {
            $this->_baseUriWithSlash = $this->_baseUriWithSlash . '/';
        }

        $this->Accept = Resource::Accept_ATOM;
        $this->Content_Type = Resource::Content_Type_ATOM;
        $this->UsePostTunneling = false;
        $this->_saveChangesOptions = Resource::DefaultSaveChangesOptions;
        $this->_replaceOnUpdateOption = false;
    }