我得到一個故障在我的web應用程序中調用一個Web服務:web服務的調用失敗,HTTP狀態400錯誤的請求
服務器錯誤/ zVersion2a「應用程序。 請求失敗,HTTP狀態400:錯誤請求。
下面是對Web服務本身的鏈接(這工作):
http://www.zipeee.com/Zipeeewebservice/
這裏是到[製作] Web應用程序的鏈接,呼籲第一頁面加載WS:
下面是失敗調用此相同的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的此生產Web服務器上,默認網站(Zipeee,zVersion2,ZipeeeWebService)中有3個虛擬目錄。
每個虛擬目錄指向Web服務器的C驅動器上的一個單獨的物理目錄。生產Zipeee和newVersion zVersion2都使用代理類ProxyZipeeeService.dll。我在發佈主要項目Zipeee和它所需的Web服務時非常謹慎。例如,在使用Visual Studio2008的開發服務器上,我已經構建和測試了所有5個項目(webservice1,webservice2,primarywebapp(egzipeee),代理類對WS1,代理類對WS2)。所有這些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。 (System.Xml.Serialization.XmlMapping []#40041277 = [356],ProxyZipeeeService.WSZipeee.Zipeee#50200644 = ProxyZipeeeService.WSZipeee.Zipeee) 調用方:System.Web.Services.Protocols.SoapClientType# 24827179 ::。構造函數(ProxyZipeeeService.WSZipeee.Zipeee#50200644 = ProxyZipeeeService.WSZipeee。Zipeee) 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58:45.6541439Z 時間戳= 47298006836 System.Web.Services.Asmx信息:0:從XmlSerializer的返回[創建的XmlSerializer] 呼叫者:System.Web.Services.Protocols.SoapClientType#24827179 ::構造函數(ProxyZipeeeService.WSZipeee.Zipeee#50200644 = ProxyZipeeeService.WSZipeee.Zipeee) 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 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 ::構造函數(ProxyEmergencyService.WSEmergency.Emergency#88831384 = ProxyEmergencyService.WSEmergency.Emergency) 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58 :45.8572390Z Timestamp = 47298680452 System.Web.Services.Asmx信息:0:從XmlSerializer返回[Create XmlSerializer] 調用方:System.Web.Services.Protocols.SoapClientType#46729429 ::。ctor(ProxyEmergencyService.WSEmergency.Emergency #88831384 = ProxyEmerge ncyService.WSEmergency.Emergency) 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58:45.9353525Z 時間戳= 47298924420 System.Web.Services.Asmx信息:0:調用XmlSerializer的[寫請求] 方法:Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer192#13256970 ::序列化(System.Xml.XmlTextWriter#52203868 = ..,System.Object的[]#72766 = [1],(空),(空) ) 來電:ProxyZipeeeService.WSZipeee.Zipeee#654897 ::序列化() 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58:46.0915795Z 時間戳= 4729959 8906 System.Web.Services.Asmx信息:0:從XmlSerializer的返回[寫請求] 主叫:ProxyZipeeeService.WSZipeee.Zipeee#654897 ::序列化() 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010 -08-06T01:58:46.0915795Z 時間戳= 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.091 5795Z 時間戳= 47299607492 System.Web.Services.Asmx錯誤:0:在ProxyZipeeeService.WSZipeee.Zipeee中捕獲的異常#654897 :: GetWebResponse。 System.Net.WebException:遠程服務器返回錯誤:(400)錯誤的請求。 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58:46.0915795Z 時間戳= 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 日期時間= 2010-08-06T01:58:46.0915795Z 時間戳= 47299654807 System.Web.Services.Asmx信息:0:調用XmlSerializer的[寫請求] 方法:Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer192#13256970 :: Serialize(System.Xml.XmlTextWriter#53046711 = ..,System.Object []#7658356 = [1],(null),(null )) 來電:ProxyZipeeeService.WSZipeee.Zipeee#1816341 ::序列化() 的ProcessID = 1456 LogicalOperationStack = 的ThreadId = 1 日期時間= 2010-08-06T01:58:56.9024879Z 時間戳= 47338202360
非常感謝您的建議。 Service Reference和ZipeeeSoapClient向我建議WCF。我正在使用ASMX,現在無法轉換。 WS1是ZipeeeWebService的縮寫,對此的調用似乎是失敗的。 WS2只是另一個web服務的簡寫(這裏沒有問題)。也許我誤解了你的想法? – 2010-08-07 02:24:19