Asmx Web 服务 500 错误

问题描述 投票:0回答:2

我有一个简单的网络服务(asmx)。我说简单是因为在故障排除过程中,我实际上删除了除“Return”语句之外的每一行代码。该服务只需获取请求并返回一个字符串即可。

我尝试了 3 或 4 种不同的方法来调用 Web 服务,每次都会返回错误:500 错误内部服务器错误

如果我在浏览器中访问服务 URL,它会正常加载并显示方法、请求示例等。

这是我的网络服务的代码

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class CalendarSyncService
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function SendXml(ByVal cBody As String) As String

    Return "Test"
End Function

End Class

该页面从不记录任何错误并且可以在浏览器中运行,因此我很难对其进行故障排除。它可以在浏览器中工作,但在通过 httprequest、webrequest、soap 等调用时却给出 500 错误,这是否有原因?

asp.net vb.net web-services asmx
2个回答
0
投票

运行 Fiddler 并检查您的调用,看看在浏览器中调用它与以编程方式调用它时有什么区别。


0
投票

我遇到了类似的问题,Web 服务在本地服务器上运行良好,但在托管服务器上返回 500 内部错误。 只需将其添加到您的 web.config 中

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>
© www.soinside.com 2019 - 2024. All rights reserved.