我的 Web 应用程序调用 Web 服务时出现故障:
“/zVersion2a”应用程序中的服务器错误。请求失败,HTTP 状态为 400:错误请求。
这是指向网络服务本身的链接(有效):
http://www.zipeee.com/Zipeeewebservice/
这是在第一个页面加载时调用 WS 的 [生产] Web 应用程序的链接:
以下是调用同一 WS 失败的 [newVersion] Web 应用程序的链接:
http://www.zipeee.com/zVersion2/
这是调用页面中的源代码:
Imports System.Data
Partial Class frmZipeee
Inherits System.Web.UI.Page
Public wsZipeee As New ProxyZipeeeService.WSZipeee.Zipeee
Dim dsStandardMsg As DataSet
Dim dtStandardMsg As DataTable
Dim dsRandomMsg As DataSet
Dim dtRandomMsg As DataTable
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
LoadMessage()
End If
End Sub
Private Sub LoadMessage()
Dim iCnt As Integer
Dim iValue As Integer
dsStandardMsg = Nothing
dsStandardMsg = wsZipeee.GetMessageByType(BizConstants.MsgType.Standard)
iCnt = dsStandardMsg.Tables(0).Rows.Count
If iCnt = 0 Then
Me.btnEnter.Text = "Click Here to Enter."
Else
Me.btnEnter.Text = dsStandardMsg.Tables(0).Rows(0).Item("MessageContent")
End If
dsStandardMsg.Dispose()
End Sub
End Class
这是代理中 Reference.vb 的代码:
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ZipeeeWebService/Zipeee/Get Message By Type", RequestElementName:="Get Message By Type", RequestNamespace:="http://tempuri.org/ZipeeeWebService/Zipeee", ResponseElementName:="Get Message By TypeResponse", ResponseNamespace:="http://tempuri.org/ZipeeeWebService/Zipeee", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function GetMessageByType(ByVal iMsgType As Integer) As <System.Xml.Serialization.XmlElementAttribute("Get Message By TypeResult")> System.Data.DataSet
Dim results() As Object = Me.Invoke("GetMessageByType", New Object() {iMsgType})
Return CType(results(0),System.Data.DataSet)
End Function
最后,这是webservice中的代码:
<WebMethod(MessageName:="Get Message By Type")> _
Public Function GetMessageByType(ByVal iMsgType As Integer) As DataSet
Try
'create a connection...
con = New SqlConnection(sConnZipeee)
con.Open()
command = New SqlCommand("spGetMessageByType", con)
command.CommandType = CommandType.StoredProcedure
AppendParm(command, "@MessageType", SqlDbType.Int, iMsgType)
Dim adp As SqlDataAdapter = New SqlDataAdapter(command)
Dim ds As New DataSet
adp.Fill(ds, "TableMsg")
adp.Dispose()
command.Dispose()
con.Close()
Return ds
Catch ex As SqlException
...etc. 'As I read the trace output (below) we never got here nor to SQL
在这个运行 IIS 6.0 Windows 2003 的生产网络服务器上,默认网站中有 3 个虚拟目录(Zipeee、zVersion2、ZipeeeWebService)。
每个虚拟目录都指向网络服务器 C 盘上的一个单独的物理目录。生产 Zipeeee 和 newVersion zVersion2 都使用名为ProxyZipeeeService.dll的代理类. 我在发布主要项目Zipeee 及其所需的网络服务时非常小心。例如,在使用 Visual Studio2008 的开发服务器上,我已经构建并测试了所有 5 个项目(webservice1、webservice2、primarywebapp (iezipeee)、proxyclassforWS1、proxyclassforWS2)。所有这些 DLL 的最新版本都标有选择为 1.6 的程序集版本。它们都在我的开发机器上工作,我将 WS1、WS2 和 zipeee 发布到临时服务器(IIS 6.0),它们也都在那里工作。然后我发布到托管上述 URL 的公共服务器。新版本的 Web 应用程序位于 c 盘上的单独文件夹中,并由 vDir zVersion2 指向。它应该可以工作,但由于此 WS 错误,甚至无法呈现第一页。
我跟踪了 zVersion2 的失败(它在页面加载事件中调用 webmethod GetMessageByType 并立即失败)。在这里(不是很长,但这里的格式有点乱):
System.Web.Services.Asmx 信息:0:调用 XmlSerializer [创建 XmlSerializer] 方法:System.Xml.Serialization.XmlSerializer#1669721556::FromMappings(System.Xml.Serialization.XmlMapping[]#40041277=[356], ProxyZipeeeService。 WSZipeee.Zipeee#50200644=ProxyZipeeeService.WSZipeee.Zipeee) 调用者:System.Web.Services.Protocols.SoapClientType#24827179::.ctor(ProxyZipeeeService.WSZipeee.Zipeee#50200644=ProxyZipeeeService.WSZipeee.Zipeee) ProcessId=1456 LogicalOperationStack=ThreadId =1 DateTime=2010-08-06T01:58:45.6541439Z Timestamp=47298006836 System.Web.Services.Asmx 信息:0:从 XmlSerializer 返回 [创建 XmlSerializer] 调用方:System.Web.Services.Protocols.SoapClientType#24827179:: .ctor(ProxyZipeeeService.WSZipeee.Zipeee#50200644=ProxyZipeeeService.WSZipeee.Zipeee)ProcessId = 1456 LogicalOperationStack = ThreadId = 1 DateTime = 2010-08-06T01:58:45.7791255Z Timestamp = 47298376293 System.Web.Services.Asmx信息:0:调用XmlSerializer [创建XmlSerializer]方法:System.Xml.Serialization。 XmlSerializer#1669721556::FromMappings(System.Xml.Serialization.XmlMapping[]#64844482=[160], ProxyEmergencyService.WSEmergency.Emergency#88831384=ProxyEmergencyService.WSEmergency.Emergency) 调用者:System.Web.Services.Protocols.SoapClientType#46729429 ::.ctor(ProxyEmergencyService.WSEmergency.Emergency#88831384=ProxyEmergencyService.WSEmergency.Emergency) ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:45.8572390Z Timestamp=47298680452 System.Web.Services.Asmx 信息: 0 : 从 XmlSerializer 返回 [创建 XmlSerializer] 调用者:System.Web.Services.Protocols.SoapClientType#46729429::.ctor(ProxyEmergencyService.WSEmergency.Emergency#88831384=ProxyEmergencyService.WSEmergency.Emergency) ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:45.9353525Z Timestamp=47298924420 System.Web.Services.Asmx 信息:0:调用 XmlSerializer [写入请求] 方法:Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer192#13256970::Serialize(System.Xml.XmlTextWriter#52203868=.., System. Object[]#72766=[1], (null), (null)) 调用者:ProxyZipeeeService.WSZipeee.Zipeee#654897::Serialize() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58: 46.0915795Z Timestamp=47299598906 System.Web.Services.Asmx 信息:0:从 XmlSerializer 返回 [Write Request] 调用方:ProxyZipeeeService.WSZipeee.Zipeee#654897::Serialize() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp=47299606361 System.Web.Services.Asmx 信息:0:调用 WebRequest.GetResponse方法:System.Net.HttpWebRequest#5894079::GetResponse() 调用者:ProxyZipeeeService.WSZipeee.Zipeee#654897::GetWebResponse() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp= 47299607492WSZipeee.Zipeee#654897::GetWebResponse() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp=47299607492WSZipeee.Zipeee#654897::GetWebResponse() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp=47299607492 System.Web.Services.Asmx 错误:0:在 ProxyZipeeeService.WSZipeee.Zipeee#654897::GetWebResponse 中捕获异常。 System.Net.WebException:远程服务器返回错误:(400)错误请求。ProcessId=1456 LogicalOperationStack=ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp=47299629487 System.Web.Services.Asmx 错误:0:异常详细信息:System.Net.WebException:远程服务器返回错误: (400) 错误请求。在 System.Net.HttpWebRequest.GetResponse() 在 System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest 请求) ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58:46.0915795Z Timestamp=47299654807 System .Web.Services.Asmx 信息:0:调用 XmlSerializer [写入请求] 方法:Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer192#13256970::Serialize(System.Xml.XmlTextWriter#53046711=.., System.