我在Web应用程序中使用WCF服务时遇到以下异常(WCF服务以Json格式提供响应) [英] I got the following exception while consuming the WCF service in web application(WCF service gives response in Json Format)

查看:76
本文介绍了我在Web应用程序中使用WCF服务时遇到以下异常(WCF服务以Json格式提供响应)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有端点侦听可以接受该消息的http:// localhost:7783 / GetDataService.svc / JSONData。这通常是由错误的地址或SOAP操作引起的。有关详细信息,请参阅InnerException(如果存在)。

解决方案

您好Ganesh,



我遇到了同样的问题在clint apllication。但是当我在服务界面中更改属性时它起作用如下:



[WebInvoke(Method =GET,ResponseFormat = WebMessageFormat.Json,

BodyStyle = WebMessageBodyStyle.Bare)]


您好Ganesh,



查看服务网址(通过在Internet Explorer等任何浏览器中打开它来检查URL。): http:// localhost:7783 / GetDataService.svc / JSONData [ ^ ]是否正在运行。 />


如果没有,那么您必须右键单击SVC文件并选择在Web浏览器中打开选项。



这可以解决问题。但如果您仍然遇到问题,请告诉我。


服务配置文件:

 <?  xml    版本  =  1.0  >  
< configuration >

< < span class =code-leadattribute> system.web >
< 编译 debug = true targetFramework = 4.0 / >
< / system.web < span class =code-keyword>>
< system.serviceModel >
< behavior >
< serviceBehaviors >
< 行为 >
<! - 为避免泄露元数据信息,请将以下值设置为false,在部署之前删除上面的元数据端点 - >
< serviceMetadata httpGetEnabled = true / >
<! - 要接收故障中的异常详细信息以进行调试,请将以下值设置为true。在部署之前设置为false以避免泄露异常信息 - >
< serviceDebug includeExceptionDetailInFaults = false / >
< / behavior < span class =code-keyword>>
< / serviceBehaviors >
< / behavior >
< serviceHosting环境 multipleSiteBindingsEnabled = true / >
< / system.serviceModel < span class =code-keyword>>
< system.webServer >
< modules runAllManagedModulesForAllRequests = true / >
< span class =code-keyword>< / system.webServer >

< / configuration >







App配置文件:



 < span class =code-keyword><   pre  >  
< 配置 >

< system.servicemodel >
< bindings > ;
< basichttpbinding >
< binding 名称 = BasicHttpBinding_IMainService closetimeout = 00:01:00 >
openTimeout =00:01:00 receiveTimeout =00:10:00sendTimeout =00:01:00
allowCookies =falsebypassProxyOnLocal =falsehostNameComparisonMode =StrongWildcard
maxBufferSize =65536maxBufferPoolSize = 524288maxReceivedMessageSize =65536
messageEncoding =TexttextEncoding =utf-8transferMode =Buffered
useDefaultWebProxy =true>
< readerquotas < span class =code-attribute> maxdepth = 32 maxstringcontentlength = 8192 maxarraylength = 16384 >
maxBytesPerRead =4096maxNameTableCharCount =16384/> ;
< security < span class =code-attribute> mode = >
< transport clientcredentialtype = proxycredentialtype = >
realm =/>
< 消息 < span class =code-attribute> clientcredentialtype = UserName algorithmsuite = 默认 / >
< / transport > < / security >
< / readerquotas > < / binding >
< span class =code-keyword>< / basichttpbinding >
< / bindings >
< 客户 >
< endpoint < span class =code-attribute> address = http:// localhost:1298 / MainService。 svc binding = basicHttpBinding >
bindingConfiguration =BasicHttpBinding_IMainServicecontract =MainServiceAgent.IMainService
name =BasicHttpBinding_IMainService/>
< / endpoint > < / client >
< / system.servicemodel >
< / configuration >


There was no endpoint listening at http://localhost:7783/GetDataService.svc/JSONData that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

解决方案

Hi Ganesh,

I got same issue at clint apllication. But it worked when i change property in service interface like below:

[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]


Hi Ganesh,

Check the service url (Check the url by opening it in any browser like Internet explorer.): http://localhost:7783/GetDataService.svc/JSONData[^] whether it is running or not.

If not, then you have to right click on the SVC file and select open in web browser option.

This could resolve the issue. But if you still face the issue please let me know.


Service config file:

<?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 and remove the metadata endpoint above 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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>




App Config file:

<pre>
<configuration>
  
    <system.servicemodel>
        <bindings>
            <basichttpbinding>
                <binding name="BasicHttpBinding_IMainService" closetimeout="00:01:00">
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
                        <message clientcredentialtype="UserName" algorithmsuite="Default" />
                    </transport></security>
                </readerquotas></binding>
            </basichttpbinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1298/MainService.svc" binding="basicHttpBinding">
                bindingConfiguration="BasicHttpBinding_IMainService" contract="MainServiceAgent.IMainService"
                name="BasicHttpBinding_IMainService" />
        </endpoint></client>
    </system.servicemodel>
</configuration>


这篇关于我在Web应用程序中使用WCF服务时遇到以下异常(WCF服务以Json格式提供响应)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆