0
我正在尝试调用wsdl未在其网站上发布的Web服务。该服务的开发人员给了我wsdl文件来从中生成代理类。不调用Web服务的代理类
我已经使用VS2010 svcutil.exe命令成功生成了该文件。我将这个文件包含在我正在处理的项目中,但是,在调用webservice时,没有任何请求会通过fiddler2来证明,我用它来检查传出的请求和响应。
对于下面的文件,我将从数据库中获取数据,但出于测试原因,我只是通过静态信息发送。 app.config文件==的
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
==部分
<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
哦,谢谢你,约翰,我已经包括进口MusicShop.Album.Song在应用程序文件中按编辑的代码,但仍然返回空响应,我是否错过了什么地方? – user2211448 2013-03-27 07:43:17