我有一个使用wcf Web服务的Web项目,它不能正常工作。
在这里我包括web配置文件以获得更多理解:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="FolderPath" value="excel/"/>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>
</appSettings>
<system.Web>
<httpRuntime targetFramework="4.6.1" />
</system.Web>
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<compilation debug="true" targetFramework="4.6.1">
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</buildProviders>
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<httpRuntime maxRequestLength="2147483647" executionTimeout="99999999"/>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear/>
<add value="Login.aspx"/>
</files>
</defaultDocument>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="ChartImageHandler"/>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="LargeWeb" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="infinite">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://staffapi.vayak.net/staff_care_wcf_ws/RestServiceImpl.svc" binding="webHttpBinding" bindingConfiguration="LargeWeb" contract="SC_WCF.IRestServiceImpl" name="" behaviorConfiguration="web"/>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
当应用程序请求时,它给了我这样的帖子标题错误
在这里,我包括我的方法来调用此服务。
public void Fill_Combo(Page pg, DropDownList ddl, string combo_type, int Active_Only = 1, int Help_ID = 0, int All_Req = 1, string All_Str = "All", string Filter_Str = "")
{
cls_combo obj = new cls_combo();
cls_combo[] obj_li = null;
try
{
cls_combo_in obj_in = new cls_combo_in();
obj_in.db_name = CommonLogic.GetSessionValue("sdb_name");
obj_in.Combo_Type = combo_type;
obj_in.Active_Only = Active_Only;
obj_in.help_id = Help_ID;
obj_in.Add_Str_Req = All_Req;
obj_in.Add_Str = All_Str;
obj_in.Staff_ID = Convert.ToInt32(CommonLogic.GetSessionValue("staff_id"));
obj_in.Is_Admin = Convert.ToBoolean(CommonLogic.GetSessionValue("is_admin")) == true ? 1 : 0;
obj_li = obj_main.get_combo(obj_in);
if (obj_li.Length > 0)
{
ddl.DataSource = obj_li;
ddl.DataTextField = "Value";
ddl.DataValueField = "ID";
ddl.DataBind();
}
else
{
CommonLogic.SetSessionValue("combo_type", combo_type);
pg.Response.Redirect("alert.aspx");
}
}
catch (Exception ex)
{
CommonLogic.SendMailOnError(ex);
}
}
我不明白这里有什么问题请帮助我们..
我们应该将[WebGet] / [WebInvoke]添加到接口的自动生成操作中,以便它保持服务器和客户端之间绑定的一致性。它位于自动生成的客户端代理类中。 我们通过添加服务引用来使用WCF服务,使用WebHttpBinding创建服务时会有所不同。这种类型的服务通常称为Restful style服务,我们可以通过在浏览器中输入服务地址来直接调用它。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service 因此,如果我们想通过使用客户端代理类来使用服务,我们需要维护服务器和客户端之间绑定的一致性,就像WCF SOAP服务一样。 如果问题仍然存在,请随时与我联系。