我正在使用WCF服务,其wsdl未在网站上发布。该服务的开发人员已经给了我wsdl文件来从中生成代理类。
我已使用VS2010 svcutil.exe命令成功生成了该文件。我将该文件包含在我正在处理的项目中,但是,在调用webservice时,没有请求从代理类发送到webservice主机,这可以通过我用来检查传出请求和响应的第三方数据包嗅探器来证明
我只是通过静态信息发送
我是WCF服务的新手,所以请告知我是否需要添加一部分。
Imports System.Data
Imports System.ServiceModel
Imports System.Web.UI.Page
Imports System.Math
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() = "TakeMeHome"
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>
代理类的一部分
Imports System.Runtime.Serialization
<Assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://ucizi.music/DataContracts", ClrNamespace:="ucizi.music.DataContracts")>
Namespace ucizi.music.DataContracts
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="Request", [Namespace]:="http://ucizi.Music/DataContracts")> _
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.albumtitlebox
End Get
Set(ByVal value As String)
Me.albumtitlebox = Value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True, Order:=2)> _
Public Property songname() As String
Get
Return Me.songnamebox
End Get
Set(ByVal value As String)
Me.songnamebox = value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True, Order:=3)> _
Public Property tracknumber() As Integer
Get
Return Me.tracknumberbox
End Get
Set(ByVal value As Integer)
Me.tracknumberbox = value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True, Order:=4)> _
Public Property language() As String
Get
Return Me.languagebox
End Get
Set(ByVal value As String)
Me.languagebox = value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True, Order:=5)> _
Public Property requestnumber() As UInteger
Get
Return Me.requestnumberbox
End Get
Set(ByVal value As UInteger)
Me.requestnumberbox = value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=True, Order:=6)> _
Public Property totalAlbums() As Integer
Get
Return Me.totalAlbumsbox
End Get
Set(ByVal value As Integer)
Me.totalAlbumsbox = value
End Set
End Property
End Class
'rest of codes
End Namespace
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), _
System.ServiceModel.ServiceContractAttribute([Namespace]:="http://ucizi.music/ServiceContracts", ConfigurationName:="MusicServiceContract")> _
Public Interface MusicServiceContract
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message SubmitRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"ayment", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"aymentResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"aymentGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function SubmitPayment(ByVal request As SubmitRequest) As SubmitPaymentResponse
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message SubmitReversalRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitR" & _
"eversal", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitR" & _
"eversalResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitR" & _
"eversalGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function SubmitReversal(ByVal request As SubmitReversalRequest) As SubmitReversalResponse
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message GetPaymentConfRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/Payment" & _
"Confirmation", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/Payment" & _
"ConfirmationResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/Payment" & _
"ConfirmationGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function PaymentConfirmation(ByVal request As GetPaymentConfRequest) As GetPaymentConfResponse
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message GetAvailableMOPRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetAvai" & _
"lableMethodOfPayments", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetAvai" & _
"lableMethodOfPaymentsResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetAvai" & _
"lableMethodOfPaymentsGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function GetAvailableMethodOfPayments(ByVal request As GetAvailableMOPRequest) As GetAvailableMOPResponse
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message GetTransactionHistoryRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetTran" & _
"sactionHistory", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetTran" & _
"sactionHistoryResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/GetTran" & _
"sactionHistoryGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function GetTransactionHistory(ByVal request As GetTransactionHistoryRequest) As GetTransactionHistoryResponse
'CODEGEN: Generating message contract since the wrapper namespace (http://ucizi.music/MessageContracts) of message SubmitSmartCardRequest does not match the default value (http://ucizi.music/ServiceContracts)
<System.ServiceModel.OperationContractAttribute(Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"aymentUsingSmartCard", ReplyAction:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"aymentUsingSmartCardResponse"), _
System.ServiceModel.FaultContractAttribute(GetType(ucizi.music.DataContracts.GeneralFaultContract), Action:="http://ucizi.music/ServiceContracts/MusicServiceContract/SubmitP" & _
"aymentUsingSmartCardGeneralFaultContractFault", Name:="GeneralFaultContract", [Namespace]:="http://ucizi.music/DataContracts")> _
Function SubmitPaymentUsingSmartCard(ByVal request As SubmitSmartCardRequest) As SubmitPaymentResponse
End Interface
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), _
System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), _
System.ServiceModel.MessageContractAttribute(WrapperName:="SubmitRequest", WrapperNamespace:="http://ucizi.music/MessageContracts", IsWrapped:=True)> _
Partial Public Class SubmitRequest
<System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://ucizi.music /ServiceContracts", Order:=0)> _
Public Request As ucizi.music.DataContracts.Request
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal Request As ucizi.music.DataContracts.Request)
MyBase.New()
Me.Request = Request
End Sub
End Class
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
Partial Public Class MusicServiceContractsClient
Inherits System.ServiceModel.ClientBase(Of MusicServiceContracts)
Implements MusicServiceContracts
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
<System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> _
Function MusicServiceContract_SubmitRequest(ByVal request As SubmitMusicRequest) As SubmitMusicResponse Implements MusicServiceContracts.SubmitMusic
Return MyBase.Channel.SubmitMusic(request)
End Function
Public Function SubmitMusic(ByVal PaymentRequest As multichoice.paymentservice.DataContracts.PaymentRequest) As multichoice.paymentservice.DataContracts.TransactionResponse
Dim inValue As SubmitMusicRequest = New SubmitMusicRequest()
inValue.PaymentRequest = PaymentRequest
Dim retVal As SubmitMusicResponse = CType(Me, MusicServiceContracts).SubmitMusic(inValue)
Return retVal.PaymentResponse
End Function
End Class
答案 0 :(得分:1)
您目前只是new
回复。您需要创建一个服务客户端并使用它来调用服务以获得响应。
我是C#开发人员,但我想这样的事情:
Dim client as New MusicServiceContractsClient
Dim songresponse = client.SubmitMusic(request)