This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Cannot Consume Aras web service in php

Saurabh T - Tuesday, February 7, 2012 9:20 AM:

I have created a web service in aras and I have created a web client in PHP from which I am trying to consume the aras web service. But when I am trying to call a Method in web service but  I am getting an error

 

Array ( [faultcode] => soap:Server [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Aras.Tools.WebServices.LogOnException: ERROR: You are not logged in to Innovator. at Aras.Tools.WebServices.InnovatorWS.CheckAuthorization() in c:Program Files (x86)ArasInnovatorInnovatorWebServices estApp_CodeInnovator.asmx.cs:line 150 at Aras.Tools.WebServices.InnovatorWS._Apply(String methodName, String aml) in c:Program Files (x86)ArasInnovatorInnovatorWebServices estApp_CodeInnovator.asmx.cs:line 279 at Aras.Tools.WebServices.InnovatorWS.ApplyMethod(String methodName, String methodData) in c:Program Files (x86)ArasInnovatorInnovatorWebServices estApp_CodeInnovator.asmx.cs:line 84 --- End of inner exception stack trace --- [detail] => )

 

 

 



eric_h - Tuesday, February 7, 2012 12:41 PM:

Saurabh,

I don't know if this is always the case, but any time I have tried to access the Aras server outside of the standard client (in my case mostly in JavaScript), I needed to set the username and password in the Header that I passed to the Aras server. On a related note, the password needs to be sent as the MD5 hashed value. I think (don't quote me on this) that the standard client retains some sort of token or cookie value for future authentications, but I don't know the mechanism behind this so it has been easier to just send the credentials every time.

I used jQuery in doing this because it made the Ajax call to the server easier, but here is a sample of using the jQuery .ajax method I used. The "beforeSend" aspect sets the various header values. You may have to look up how this works, but also find ways to set headers in PHP:

$.ajax({
    type: "POST",
    url: "lbu-ws2008e/.../InnovatorServer.aspx",
    beforeSend: function(xhr) {
        xhr.setRequestHeader('SOAPACTION', 'ApplyItem');
        xhr.setRequestHeader('AUTHUSER', 'admin');
        xhr.setRequestHeader('AUTHPASSWORD', '607920b64fe136f9ab2389e371852af2');
        xhr.setRequestHeader('DATABASE', 'InnovatorSolutions');
        xhr.setRequestHeader('LOCALE', 'en-US');
        xhr.setRequestHeader('TIMEZONE_NAME', 'Mountain Standard Time');
    }, .........

 

Eric



Saurabh T - Wednesday, February 8, 2012 3:55 AM:

Hello Eric,

Even I am trying to access Aras server from php client. In this PHP client I have mentioned username and password in the SOAP header. But the problem is that this username and password is not getting invoked. As a result when I call a Apply Method function it gives the above error. 

 

Regards,

Saurabh



eric_h - Wednesday, February 8, 2012 10:57 AM:

Saurabh,

There may be a way to pass the user name and password in the SOAP header (or envelope?), but what I was doing passes these via the HTTP header itself. Someone else I was talking with did the same thing. I figured this out by watching the packet transfers between the Aras client and server. Not saying this is the best method, but what I figured out. Take a look at the attached picture for what I mean. These six header items are above and beyond the normal HTTP header information that would get sent; the function I included above adds these six items to the header that is sent with the AJAX request to the server. Actually, if you look further down, you will see the cookie, and that one key has a name of "ASP.NET_SessionID". I have a feeling this is used by the official client to establish a logged in session. But not sure - in my case I just passed the headers each time. Not sure how you would do this in PHP, but I am pretty sure it has a function that allows you to change / add to the HTTP header. Hope this might help a little.

Eric