我创建了一个包含表、数据/服务合同类以及服务和服务组的测试项目,如下所示:
部署后,我什至可以使用 .Net 控制台应用程序访问和查看 GetEntityList 数据
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();
问题是我需要使用 SOAP 客户端访问它,尝试创建大量 SOAP 信封消息但无法查看服务数据。我认为我可能缺少的是 SOAP 标头中正确的身份验证标签,我不知道,请指定。
到目前为止我尝试过的标题是这样的:
<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>
更新:正如我提到的,我可以使用 .Net 控制台应用程序访问 Web 服务,但是当我执行 Visual Studio 命令行工具 > WCFTestClient > 添加服务时它也不起作用。它不允许在那里添加服务并给出以下错误:
命名空间“Microsoft.Dynamics.Ax”中不存在类型或命名空间名称“Application”(您是否缺少程序集引用
任何帮助将不胜感激。