微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 从unity3D消耗WCF

我有一些wcf webservices,我在IIS上托管在localhost上.
我希望能够从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类.

解决方法:

using System.ServiceModel;

我的课程实现中缺少此声明.

我这样称呼webservice:

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐