Dan*_*Gee 6 vb.net asp.net web-services
我可以看到这个问题已被多次询问,但它们都与WCF有关.搜索一段时间后,我一直无法找到此错误的解决方案.
我有一个WinForms应用程序从Web服务中提取数据.Web服务是用WebForms/asp.net编写的.
我连接到Web服务的代码是:
Dim _DownloadStock As srShopDownload.shop_downloadsSoapClient
Dim binding As New STKBinding("STKBinder")
NewEndPoint = New EndpointAddress("https://www.example.com/web_services/downloads.asmx")
_DownloadStock = New srShopDownload.shop_downloadsSoapClient(binding._Binder, NewEndPoint)
_StockcodesList = _DownloadStock.GetStockcodes
Run Code Online (Sandbox Code Playgroud)
我的_Binder代码是
Public Sub New(ByVal BinderName As String)
_Binder = New BasicHttpBinding()
_Binder.Name = BinderName
_Binder.CloseTimeout = TimeSpan.FromMinutes(1)
_Binder.OpenTimeout = TimeSpan.FromMinutes(1)
_Binder.ReceiveTimeout = TimeSpan.FromMinutes(10)
_Binder.SendTimeout = TimeSpan.FromMinutes(1)
_Binder.AllowCookies = False
_Binder.BypassProxyOnLocal = False
_Binder.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
_Binder.MaxBufferSize = 100000000
_Binder.MaxBufferPoolSize = 12000000
_Binder.MaxReceivedMessageSize = 100000000
_Binder.MessageEncoding = WSMessageEncoding.Text
_Binder.TextEncoding = System.Text.Encoding.UTF8
_Binder.TransferMode = TransferMode.Streamed
_Binder.UseDefaultWebProxy = True
_Binder.ReaderQuotas.MaxDepth = 2147483647
_Binder.ReaderQuotas.MaxStringContentLength = 2147483647
_Binder.ReaderQuotas.MaxArrayLength = 2147483647
_Binder.ReaderQuotas.MaxBytesPerRead = 2147483647
_Binder.ReaderQuotas.MaxNameTableCharCount = 2147483647
_Binder.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
_Binder.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None
_Binder.Security.Transport.Realm = ""
_Binder.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName
_Binder.Security.Message.AlgorithmSuite = Security.SecurityAlgorithmSuite.Default
_Binder.Security.Mode = BasicHttpSecurityMode.Transport
End Sub
Run Code Online (Sandbox Code Playgroud)
在Web服务方面,它只是一个基本功能:
<WebMethod()>
Public Function GetStockcodes() As List(Of Stockcodes)
Return GetStockcodes()
End Function
Run Code Online (Sandbox Code Playgroud)
我已经看到了应该更改客户端和服务器上的serviceBehaviors的答案,但我不知道如何在不使用WCF的情况下执行此操作.
我找到了一个解决方法,只是放在这里以防有人遇到同样的问题。
在 PC 上打开此文件夹。它是 .NET Framework 文件夹:%windir%\Microsoft.NET\
在此目录中,您应该看到文件夹:Framework 和 Framework64(在 64 位环境中)。这两个文件夹都包含一些具有特定 .NET 版本名称的文件夹(例如 v2.0.50727)。您需要浏览每个文件夹并查看它是否包含 CONFIG 目录以及名为 machine.config 的文件。(或者只是搜索 machine.config)
打开并编辑每个 machine.config 文件,并在 system.serviceModel 节点下添加以下子节点:
<commonBehaviors>
<endpointBehaviors>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</endpointBehaviors>
<serviceBehaviors>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</serviceBehaviors>
</commonBehaviors>
Run Code Online (Sandbox Code Playgroud)
<system.serviceMode>
(...)
<extensions>
(...)
</extensions>
<client>
(...)
</client>
<commonBehaviors>
<endpointBehaviors>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</endpointBehaviors>
<serviceBehaviors>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</serviceBehaviors>
</commonBehaviors>
(...)
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
如果配置文件中缺少system.serviceModel节点,则需要手动创建该节点。
重新启动应用程序。如果仍然无法正常工作,您可能需要重新启动电脑。
我在此链接中找到了解决方案。只需将答案放在这里,以防将来页面出现故障。
| 归档时间: |
|
| 查看次数: |
263 次 |
| 最近记录: |