【发布时间】:2010-01-19 06:14:03
【问题描述】:
我想问一个问题。我的一位前同事写了一个 window azure 项目,现在我需要继续这个项目。 Web 服务在那个窗口 azure 项目中,我需要在 silverlight 中调用该 Web 服务。因此,我在现有的 Window azure 项目中添加了新的 silverlight 项目。当我尝试在 silverlight 应用程序中添加服务参考时。它显示“未找到与 Silverlight3 兼容的端点”,并且无法创建 ServiceReference.config 文件。
我不太喜欢 web 服务和 c#。那么,你能告诉我在 Silverlight 使用 Web 服务的步骤吗?
我还尝试更改 Web.config 文件中的“basicHttpBinding”和“customBinding”。但它不允许我改变任何东西。那么,在不改变服务器端的任何东西的情况下,如何在 silverlight 中调用 webservice?
这是部分代码。
IEventHandler.cs
`[OperationContract]
[WebGet(UriTemplate = "Holidays", ResponseFormat = WebMessageFormat.Xml)]
List<Holidays> GetHolidays();`
EventHandler.svc
`public List<Holidays> GetHolidays()
{
//database declaration for purpose of accessing the db.
Database db = new Database();
//dg.getHolidays is found in the Database class.
List<Holidays> holidays = db.getHolidays();
return holidays;
}`
Web.config
`<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" >
<readerQuotas
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
<!--<security mode="Transport">
</security>-->
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Rest_EventHandler_WebRole.EventHandlerBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Rest_EventHandler_WebRole.EventHandlerBehavior"
name="Rest_EventHandler_WebRole.EventHandler">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding"
bindingConfiguration="webBinding" contract="Rest_EventHandler_WebRole.IEventHandler">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>`
对于silverlight,我如何调用该WebService?我无权更改服务器端部分。我需要使用 sisvcutil.exe 吗?你能帮我解决我的问题吗?
【问题讨论】: