Click here to Skip to main content
15,895,829 members

How can i call a WCF Service

Sina asefi asked:

Open original thread
Hi every one
i have a wcf service (Chat_Server)
and i made a web.config and callback class with command :
VB
svcutil.exe http://localhost:1462/Service_Chat.svc?wsdl

this is my config :
XML
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IService_Chat">
          <reliableSession inactivityTimeout="00:01:00" />
          <security mode="None" />
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:1462/Service_Chat.svc" binding="wsDualHttpBinding"
          bindingConfiguration="WSDualHttpBinding_IService_Chat" contract="IService_Chat"
          name="WSDualHttpBinding_IService_Chat" />
    </client>
  </system.serviceModel>
</configuration>


and this is my class with (Service_ChatClient) name :

VB
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.17929
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On



<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), _
 System.ServiceModel.ServiceContractAttribute(ConfigurationName:="IService_Chat", CallbackContract:=GetType(IService_ChatCallback), SessionMode:=System.ServiceModel.SessionMode.Required)> _
Public Interface IService_Chat

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/Connect")> _
    Sub Connect(ByVal Username As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/SendMessage")> _
    Sub SendMessage(ByVal Username As String, ByVal message As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/OnMessage")> _
    Sub OnMessage(ByVal message As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/Disconnect")> _
    Sub Disconnect(ByVal Username As String)
End Interface

<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
Public Interface IService_ChatCallback

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/Connect")> _
    Sub Connect(ByVal Username As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/SendMessage")> _
    Sub SendMessage(ByVal Username As String, ByVal message As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/OnMessage")> _
    Sub OnMessage(ByVal message As String)

    <System.ServiceModel.OperationContractAttribute(IsOneWay:=True, Action:="http://tempuri.org/IService_Chat/Disconnect")> _
    Sub Disconnect(ByVal Username As String)
End Interface

<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
Public Interface IService_ChatChannel
    Inherits IService_Chat, System.ServiceModel.IClientChannel
End Interface

<System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
Partial Public Class Service_ChatClient
    Inherits System.ServiceModel.DuplexClientBase(Of IService_Chat)
    Implements IService_Chat

    Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext)
        MyBase.New(callbackInstance)
    End Sub

    Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String)
        MyBase.New(callbackInstance, endpointConfigurationName)
    End Sub

    Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
        MyBase.New(callbackInstance, endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(callbackInstance, endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(callbackInstance, binding, remoteAddress)
    End Sub

    Public Sub Connect(ByVal Username As String) Implements IService_Chat.Connect
        MyBase.Channel.Connect(Username)
    End Sub

    Public Sub SendMessage(ByVal Username As String, ByVal message As String) Implements IService_Chat.SendMessage
        MyBase.Channel.SendMessage(Username, message)
    End Sub

    Public Sub OnMessage(ByVal message As String) Implements IService_Chat.OnMessage
        MyBase.Channel.OnMessage(message)
    End Sub

    Public Sub Disconnect(ByVal Username As String) Implements IService_Chat.Disconnect
        MyBase.Channel.Disconnect(Username)
    End Sub
End Class


Now i don't know how can i make a new class of my ( Service_ChatClient ) and call it methods?
thank you.
Tags: C#, Visual Basic, WCF

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900