wsdlがWebサイトに公開されていないWebサービスを呼び出そうとしています。サービスの開発者から、プロキシクラスを生成するためのwsdlファイルが提供されました。
VS2010svcutil.exeコマンドを使用してファイルを正常に生成しました。私が取り組んでいるプロジェクトにファイルを含めましたが、Webサービスを呼び出すときに、送信要求と応答をチェックするために使用したfiddler2によって証明されるように、送信される要求はありません。
以下のファイルでは、データベースからデータを取得しますが、テスト上の理由から、静的な情報を送信しているだけです。
Imports System.Data
Imports System.ServiceModel
Imports System.Web.UI.Page
Imports System.Math
Imports MusicShop.Album.Song
Public Class webservicetest
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Song As New request
Try
Song.songname() = "TameMeHome"
Song.trackNumber() = Convert.ToInt32("1")
Song.requestNumber() = Convert.ToInt32("5689")
Song.language() = "english"
Song.albumtitle() = "GetMeThere"
Song.totalAlbums() = Convert.ToDecimal("35")
Dim songresponse As New responce
Label1.Text = songresponse.errorMessage()
Label2.Text = songresponse.requestDateTime()
Label3.Text = songresponse.requestNumber()
Label4.Text = songresponse.status()
Finally
End Try
End Sub
End Class
==app.configファイルの一部==
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Songinformation" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="urlWherewebserviceIsDeployed"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Songinformation"
contract="Songdata" name="BasicHttpBinding_Songdata" />
</client>
</system.serviceModel>
==プロキシクラスファイルの一部==
Option Strict Off
Option Explicit On
Imports System.Runtime.Serialization
<Assembly: System.Runtime.Serialization.ContractNamespaceAttribute("URLForDataContract", ClrNamespace:="New MusicShop.Album.Song")>
Namespace New MusicShop.Album.Song
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="Request", [Namespace]:="URLforDataContract")> _
Partial Public Class Request
Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject
Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
Private albumtitle As String
Private songname = As String
Private trackNumber As Integer
Private language As String
Private requestNumber As UInteger
Private totalAlbums As Integer
Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
Get
Return Me.extensionDataField
End Get
Set(ByVal value As System.Runtime.Serialization.ExtensionDataObject)
Me.extensionDataField = Value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True)> _
Public Property albumtitle() As String
Get
Return Me.albumtitle
End Get
Set(ByVal value As String)
Me.albumtitlebox = Value
End Set
End Property