1

wsdl が Web サイトに公開されていない WCF サービスを使用しています。それ以来、サービスの開発者は、そこからプロキシ クラスを生成するための wsdl ファイルを提供してくれました。

VS2010 svcutil.exe コマンドを使用してファイルを正常に生成しました。作業中のプロジェクトにファイルを含めましたが、Web サービスを呼び出すときに、送信要求と応答を確認するために使用したサードパーティのパケット スニファーによって証明されるように、プロキシ クラスから Web サービス ホストに送信される要求はありません。 .

静的情報を送信しているだけです

私は 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
4

1 に答える 1

1

あなたは現在new、応答を行っているところです。サービス クライアントを作成し、それを使用してサービスを呼び出して応答を取得する必要があります。

私は C# 開発者ですが、次のようなものを想像します。

Dim client as New MusicServiceContractsClient
Dim songresponse = client.SubmitMusic(request)
于 2013-04-11T18:39:08.230 に答える