有关silverlight中调用webservice的问题!!

dangelrose 2010-01-06 03:25:51
有关silverlight中调用webservice的问题!!
【为什么我一定要发在silverlight版??因为我在winform程序里面用的好好的~~在sl项目里面就不能用了!!!】

System.InvalidOperationException was unhandled by user code

客户端配置部分中,找不到引用协定“webxmlWeather.WeatherWebServiceHttpGet”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。


我在里面sl调用 webservice 老是出错哦~~
说是找不到函数。恩 服务端确实没这些异步的函数。。额 是sl产生的。
哪里没配置呢??。。
该这么办呢?


错误提示:
System.InvalidOperationException was unhandled by user code
Message=在 ServiceModel 客户端配置部分中,找不到引用协定“webxmlWeather.WeatherWebServiceHttpGet”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。
StackTrace:
位于 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
位于 System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
位于 System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
位于 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
位于 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
位于 System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
位于 System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
位于 System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
位于 System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
位于 System.ServiceModel.ClientBase`1..ctor()
位于 midwareproj.webxmlWeather.WeatherWebServiceHttpGetClient..ctor()
位于 midwareproj.MainPage..ctor()
位于 midwareproj.App.Application_Startup(Object sender, StartupEventArgs e)
位于 System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
InnerException:

我的代码:
我的服务引用地址是:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx

webxmlWeather.WeatherWebServiceHttpGetClient webxmlWeather_client = new WeatherWebServiceHttpGetClient();


在这里报的错!!
...全文
449 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
bch520 2010-05-24
  • 打赏
  • 举报
回复
123123
xingjunli 2010-01-21
  • 打赏
  • 举报
回复
http://silverlightchina.net/html/tips/2009/0916/184.html
xingjunli 2010-01-21
  • 打赏
  • 举报
回复
参考http://blogs.msdn.com/brada/archive/2009/11/22/ria-services-a-domainservice-is-a-wcf-service-add-service-reference.aspx
jv9 2010-01-21
  • 打赏
  • 举报
回复
asp.net和silverlight使用的不是完全相同的.net framework,所以webservice调用代码也不能完全通用。

看看微软的例程

http://code.msdn.microsoft.com/silverlightws
http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx
mengKzhaoyun 2010-01-20
  • 打赏
  • 举报
回复
如果服务出现了跨域访问策略问题,那么你应该不能在公网访问“http://www.webxml.com.cn/WebServices/WeatherWebService.asmx”
如果,你在公网能访问上面的网址就不存在跨域问题。
mengKzhaoyun 2010-01-20
  • 打赏
  • 举报
回复
楼主在添加了Service References后,在其文件夹下应该产生一个ServiceReferences.ClientConfig的文件,这个文件里面的代码为:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WeatherWebServiceSoap" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="WeatherWebServiceSoap"
contract="WeatherWebService.WeatherWebServiceSoap" name="WeatherWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
找不到终结点就是address后面没地址或者别的,
这个文件应该是Silverlight自己自动生成的,一般不会出什么问题。
dangelrose 2010-01-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 shane007 的回复:]
引用 3 楼 dangelrose 的回复:
引用 2 楼 shane007 的回复:
需要跨域的许可文件吧。。。

domaincross.xml


但是 这个是 webservice 也需要吗??

我调用bing search 就不需要诶~

当然需要,这是处于安全方面的考虑,跨域调用一定要在服务端放置安全许可文件。

你调用bing search没有问题,是因为bing search已经做好了安全许可。
[/Quote]

恩 确实需要·~~但是那个策略文件不是服务器段配置的么?
要是不能访问我有什么办法呢?
shane007 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dangelrose 的回复:]
引用 2 楼 shane007 的回复:
需要跨域的许可文件吧。。。

domaincross.xml


但是 这个是 webservice 也需要吗??

我调用bing search 就不需要诶~
[/Quote]
当然需要,这是处于安全方面的考虑,跨域调用一定要在服务端放置安全许可文件。

你调用bing search没有问题,是因为bing search已经做好了安全许可。
dangelrose 2010-01-06
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 shane007 的回复:]
需要跨域的许可文件吧。。。

domaincross.xml
[/Quote]

但是 这个是 webservice 也需要吗??

我调用bing search 就不需要诶~
shane007 2010-01-06
  • 打赏
  • 举报
回复
需要跨域的许可文件吧。。。

domaincross.xml
dangelrose 2010-01-06
  • 打赏
  • 举报
回复
bd

8,731

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧