繁体   English   中英

从unity3D消耗WCF

[英]Consume WCF from unity3D

我有一些wcf Web服务,我在localhost上的IIS中托管。 我希望能够从Unity3d访问它们,但是在播放场景时出现以下错误:

InvalidOperationException: Client endpoint configuration 'BasicHTTPEndpoint' was not found in 0 endpoints.
System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig)
System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ChannelFactory`1[IUnityStore]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.String endpointConfigurationName)
UnityStoreClient..ctor (System.String endpointConfigurationName)
firstCall.Start () (at Assets/Scripts/firstCall.cs:8)

该Web服务的实例化为:

UnityStoreClient uc = new UnityStoreClient("BasicHTTPEndpoint");
uc.Open(); //i don't know if i need this ?????
UnityStoreLibrary.User[] users = uc.GetAllUsers("1",null);
for (int i=0;i<users.Length;i++)
    Debug.Log("username = " + users[i].username);

我的脚本文件夹中有一个配置文件,但我不知道该用它做些什么。 我从Visual Studio 2010使用svcutil创建了unity类。

使用System.ServiceModel;

我的班级实施中缺少此声明。

我这样称呼网络服务:

UnityStoreClient client = new UnityStoreClient(new BasicHttpBinding(), new EndpointAddress(some_url));

实际上,异常消息为您提供了有关缺失内容的提示。

ConfigurationManager在web.config文件的部分中找不到与WCF服务相关的任何详细信息。

有关正在调用的WCF服务的详细信息应存储在web.config文件中。 您的web.config文件中应该有一个如下的端点定义:

<system.serviceModel>
<client>
  <endpoint name="BasicHTTPEndpoint"
      address="http://myUnits3DService.svc"
      binding="basicHttpBinding"
      contract="IService"/>
 ...

也许您还应该从此处检查有关使用svcutil.exe的详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM