我在本地主机上的iis中托管了一些wcf web服务。
我想从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)
webservice的实例化方式如下:
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;
我的类实现中缺少此语句。
我这样称呼webservice:
UnityStoreClient client = new UnityStoreClient(new BasicHttpBinding(), new EndpointAddress(some_url));