Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WCF VB.NET
Hi every one
i have a wcf service (Chat_Server)
and i made a web.config and callback class with command :
svcutil.exe http://localhost:1462/Service_Chat.svc?wsdl
this is my config :
<?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 :
 
'------------------------------------------------------------------------------
' <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.
Posted 21-Mar-13 22:07pm
Edited 21-Mar-13 22:27pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You Can just create object proxy class you have generated and call the methods you want to use.
  Permalink  
Comments
Sina asefi at 22-Mar-13 11:03am
   
First thank you for your response
could you put an example?
thank you
Rohit Kumar Mumbai at 22-Mar-13 13:45pm
   
You Can Just add Above proxy class into your project. and write below code..
 
IService_Chat ObjServChat = new Service_ChatClient();
objServChat.SendMessage("","");
 
Like this.
 
Try this if not able to do then please let me know.
Cheers .
Sina asefi at 22-Mar-13 14:17pm
   
My problem is here
because if you look my Service_ChatClient class you can see it has 4 new method and they have byval parameter(s)
 
Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext)
 
Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String)
 
Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
 
Public Sub New(ByVal callbackInstance As System.ServiceModel.InstanceContext, ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
 
and so i must pass my parameter(s) to it and i don't know what are they parameters?
could you put example with pass parameter(s) to my service?
thank you.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi Sina,
 
First you have to create client object like below-
Dim cnt As New ServiceReference1.Service1Client
 
and then consume service method by using client object like below-
cnt.YourServiceMethod(param1,param2)
just as normal local method.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 10 Nov 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100