Web サービスを呼び出す Web アプリケーションでエラーが発生します。
'/zVersion2a' アプリケーションでサーバー エラーが発生しました。リクエストは HTTP ステータス 400: Bad Request で失敗しました。
これはWebサービス自体へのリンクです(これは機能します):
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 を実行しているこの運用 Web サーバーでは、既定の Web サイト (Zipeee、zVersion2、ZipeeWebService) 内に 3 つの仮想ディレクトリがあります。
各仮想ディレクトリは、Web サーバーの c ドライブにある個別の物理ディレクトリを指します。製品 Zipeee と newVersion zVersion2 の両方が ProxyZipeeService.dll と呼ばれるプロキシ クラスを使用します。. メイン プロジェクトの Zipeee とそれに必要な Web サービスの公開には細心の注意を払ってきました。たとえば、Visual Studio2008 を使用する開発サーバーで、5 つのプロジェクト (webservice1、webservice2、primarywebapp (iezipeee)、proxyclassforWS1、proxyclassforWS2) をすべてビルドしてテストしました。これらすべての DLL の最新バージョンは、1.6 に選択されたアセンブリ バージョンでタグ付けされていました。それらはすべて私の開発マシンで動作し、WS1、WS2、および zipee をステージング サーバー (IIS 6.0) に発行しましたが、すべてそこで動作します。次に、上記の URL をホストしている公開サーバーに公開します。Web アプリの新しいバージョンは、c ドライブの個別のフォルダーに移動し、vDir zVersion2 によってポイントされます。動作するはずですが、この WS エラーのため、最初のページでさえレンダリングに失敗します。
zVersion2 の失敗を追跡しました (ページ読み込みイベントで webmethod GetMessageByType を呼び出し、すぐに失敗します)。ここにあります(それほど長くはありませんが、SO here でのフォーマットは少し面倒です):
System.Web.Services.Asmx 情報: 0 : XmlSerializer の呼び出し [XmlSerializer の作成] メソッド: System.Xml.Serialization.XmlSerializer#1669721556::FromMappings(System.Xml.Serialization.XmlMapping[]#40041277=[356], ProxyZipeeService. WSZipeee.Zipeee#50200644=ProxyZipeeService.WSZipeee.Zipeee) 呼び出し元: System.Web.Services.Protocols.SoapClientType#24827179::.ctor(ProxyZipeeService.WSZipeee.Zipeee#50200644=ProxyZipeeService.WSZipeee.Zipeee) ProcessStackId=1456 ThreadOperation =1 DateTime=2010-08-06T01:58:45.6541439Z Timestamp=47298006836 System.Web.Services.Asmx 情報: 0 : XmlSerializer からの戻り [XmlSerializer の作成] 呼び出し元: System.Web.Services.Protocols.SoapClientType#24827179:: .ctor(ProxyZipeeService.WSZipeee.Zipee#50200644=ProxyZipeeService.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)) 呼び出し元: ProxyZipeeService.WSZipeee.Zipee#654897::Serialize() ProcessId=1456 LogicalOperationStack= ThreadId=1 DateTime=2010-08-06T01:58: 46.0915795Z Timestamp=47299598906 System.Web.Services.Asmx 情報: 0 : XmlSerializer からのリターン [書き込み要求] 発信者: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() 呼び出し元: ProxyZipeeService.WSZipeee.Zipee#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: ProxyZipeeService.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 システム.Web.Services.Asmx 情報: 0: XmlSerializer の呼び出し [書き込み要求] メソッド: Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer192#13256970::Serialize(System.Xml.XmlTextWriter#53046711=.., System.