加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

.NET webservice 常见问题

发布时间:2020-12-17 01:11:07 所属栏目:安全 来源:网络整理
导读:? ?一、.NET webservice 部署IIS 外网访问无法调用 ??? 今天做了一个webservice部署在服务器上之后,别人的机子访问接口只能得到接口解析信息,无法调用接口,网上查了一下,好像需要在webconfig中配置一下信息。 webServices ?? ???????? protocols ?? ????

? ?一、.NET webservice 部署IIS 外网访问无法调用

??? 今天做了一个webservice部署在服务器上之后,别人的机子访问接口只能得到接口解析信息,无法调用接口,网上查了一下,好像需要在webconfig中配置一下信息。

  1. <webServices>??
  2. ????????<protocols>??
  3. ??????????<add???name="HttpSoap"/>??
  4. ??????????<add???name="HttpPost"/>??
  5. ??????????<add???name="HttpGet"/>??
  6. ??????????<add???name="Documentation"/>??
  7. ????????</protocols>??
  8. ??????</webServices>? ?

?二、WebService应用中如果收到的信息非常大时出错

? ? ? ? ?WebService出错 Maximum message size quota for incoming messages (65536) has been exceeded.已超过传入消息(65536)的最大消息大小配额,

?1:Maximum message size quota for incoming messages (65536) has been exceeded.已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 ?
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 ??
异常详细信息: System.ServiceModel.QuotaExceededException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 ?
解决办法: ?
修改Web.Config文件,其中的MaxReceivedMessageSize ?可以改大一点,改成2147483647好了。 ?
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" ?
? ?
2:读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。 第 211 行,位置为 394。 ?
解决办法: ?
也是修改Web.Config中的MaxStringContentLength ,这是有些数据比较长的时候出现这个问题,改大一点就可以了吧。 ?
<readerQuotas maxDepth="64" maxStringContentLength="8192000" maxArrayLength="16384000" ?
? ? ? ? ? ? maxBytesPerRead="4096000" maxNameTableCharCount="16384000" /> ?
? ?
下面是完整的代码: ?
<system.serviceModel> ?
? ? <bindings> ?
? ? ? <basicHttpBinding> ?
? ? ? ? <binding name="FileServiceSoapBinding" closeTimeout="00:01:00" ?
? ? ? ? ? openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" ?
? ? ? ? ? allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" ?
? ? ? ? ? maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" ?
? ? ? ? ? messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" ?
? ? ? ? ? useDefaultWebProxy="true"> ?
? ? ? ? ? <readerQuotas maxDepth="64" maxStringContentLength="8192000" maxArrayLength="16384000" ?
? ? ? ? ? ? maxBytesPerRead="4096000" maxNameTableCharCount="16384000" /> ?
? ? ? ? ? <security mode="None"> ?
? ? ? ? ? ? <transport clientCredentialType="None" proxyCredentialType="None" ?
? ? ? ? ? ? ? realm="" /> ?
? ? ? ? ? ? <message clientCredentialType="UserName" algorithmSuite="Default" /> ?
? ? ? ? ? </security> ?
? ? ? ? </binding> ?
? ? ? ? <binding name="FileServiceSoapBinding1" closeTimeout="00:01:00" ?
? ? ? ? ? openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" ?
? ? ? ? ? allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" ?
? ? ? ? ? maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" ?
? ? ? ? ? messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" ?
? ? ? ? ? useDefaultWebProxy="true"> ?
? ? ? ? ? <readerQuotas maxDepth="64" maxStringContentLength="8192000" maxArrayLength="16384000" ?
? ? ? ? ? ? maxBytesPerRead="4096000" maxNameTableCharCount="16384000" /> ?
? ? ? ? ? <security mode="None"> ?
? ? ? ? ? ? <transport clientCredentialType="None" proxyCredentialType="None" ?
? ? ? ? ? ? ? realm="" /> ?
? ? ? ? ? ? <message clientCredentialType="UserName" algorithmSuite="Default" /> ?
? ? ? ? ? </security> ?
? ? ? ? </binding> ?
? ? ? </basicHttpBinding> ?
? ? </bindings> ?

转自:http://blog.csdn.net/susubuhui/article/details/6524158

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读