wcfaxaptasoap-clientdynamics-ax-2012aif

Unable to access AIF web service using SOAP Client


I created a test project with tables, data/service contract classes and service and service group as following:

enter image description here

After deploying, I am even able to access and view the GetEntityList data using a .Net console application

ServiceReference1.
EntityServiceClient _Client = new ServiceReference1.EntityServiceClient();
ServiceReference1.
CallContext _CallContext = new ServiceReference1.CallContext();
_CallContext.Company =
"dat";
ServiceReference1.
CustomEntityDataContract[] _entityList = _Client.GetEntityList(_CallContext);
// ColorServiceGroup.ColorDC _Dc ;
foreach (ServiceReference1.CustomEntityDataContract _Dc in _entityList)
{
Console.WriteLine(_Dc.EntityName);
}
Console.ReadKey();

The problem is that I need to access it using a SOAP Client, tried creating lots of SOAP envelope messages but unable to view the service data. What I think I could be missing is the proper authentication tags in SOAP header, which I have no idea of, plz specify.

The header I have tried so far is like:

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
    <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/dynamics/2008/01/services/EntityService/GetEntityList</a:Action>
    <h:CallContext i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://schemas.microsoft.com/dynamics/2010/01/datacontracts" />
    <a:ReplyTo>
    <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
  </s:Header>
  <s:Body>
    <EntityServiceGetEntityListRequest xmlns="http://tempuri.org" />
  </s:Body>
</s:Envelope>

UPDATE: As I mentioned that I can access the web service using .Net console application, but it also doesn't work when I do Visual Studio command line tool > WCFTestClient > Add Services. It don't allow adding service there and gives following error:

The type or namespace name 'Application' does not exist in the namespace 'Microsoft.Dynamics.Ax' (are you missing an assembly reference

Any help would be highly appreciated.


Solution

  • Deprecated the methodology of communicating directly with SOAP, instead now successfully using it with .NET console application by adding service reference. Can fetch, insert records.