【发布时间】:2014-02-13 16:02:15
【问题描述】:
文件 WebService.svc.vb
Public Class WebService
Implements IWebService
Public Function HelloThere(ByVal name As String) As String Implements IWebService.HelloThere
Return "Hello there " & name
End Function
End Class
文件 IWebService.vb
Imports System
Imports System.ServiceModel
<ServiceContract()>
Public Interface IWebService
<OperationContract()>
Function InsertReport(ByVal name As String) As String
End Interface
文件 Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WebService">
<endpoint address="WebService" binding="basicHttpBinding" contract="IWebService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
文件 WebService.svc
<%@ ServiceHost Language="VB" Debug="true" Service="WebService.WebService" CodeBehind="WebService.svc.vb" %>
我的问题是:此服务远程托管在 IIS 7(我认为是 .5)中,我想在 Web 应用程序中使用它。这个网络应用程序使用 jquery,只是一个标准的 HTML5 文档。我已经看到很多例子,人们使用一些 javascript 或 AJAX 等调用 WCF 服务... ) 修改以允许这种类型的消费。
【问题讨论】:
标签: javascript vb.net wcf web-services