.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using reflection to dynamically call a wcf webservice

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :.NET Framework

The problem: I have a test client that would like to run tests against the same webservice deployed to different servers.  I have a service reference for each of the different servers.

Progress: I am able to create an instance of each service reference (using Activator) and list the members of the service reference using reflection given that the referencing code  provides the namespace defined in the Reference.cs for the given service reference.  I am also able to create instances of other classes defined in the service reference and populate the properties of these objects.

However, when I try to access the Client using the following code, I receive the exception  "Method LGSBAClientCons.Local_Users.LGSBA_UsersClient.ClientCredentials' not found."

Object anObj = hUserType.InvokeMember(

View Complete Post

More Related Resource Links

.NET Reflection: Dynamically Bind Your Data Layer to Stored Procedures and SQL Commands Using .NET M


One major inconvenience of using SQL stored procedures from code is having to match type information. You have to write long wrapper functions around the procedures just to expose the data types. In the .NET Framework, however, the reflection services of the System.Reflection namespace allow you to query rich metadata that describe data types. This article explains how to use reflection in .NET to end your stored procedure nightmares. The author creates four custom classes, including one that generates a SQLCommand object based on the metadata of a method. Using this library, you'll be on your way to automating the generation of stored procedures.

Atif Aziz

MSDN Magazine August 2002

how to call an dll file dynamically from (.cs )


i have  an  microsoft .office.interop.excel(dll) located  at an directory d:\abc\.  now i do not want to add them  as an web reference in my projet   and  call them

rather  call the dll dynamically  from my code behind(.cs)
is ther any way  we can do dynmically

 anyhelp would be  great
 thank  you

ajax call to webservice

I am new to jquery and want to make a simple jquery ajax call to webservice. My webservice is running fine but I am unable to get the data through ajax and jquery. My code is <%@ Page Language="C#" AutoEventWireup="true" CodeFile="WS.aspx.cs" Inherits="WS" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"><title></title> <script src="jquery-1.4.2.min.js" type="text/javascript"></script> <script  type="text/javascript"> $(document).ready(function() { $("#btGetDate").click(function() { //$("#dvDate").html("I am here"); $.ajax({ type: "POST", url: "WebService.asmx/GetDateTime", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("#dvDate").html(msg); } }); }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div id="dvDate"></div><input id="btGetDate" type="button" value="Get Date" /> </div> </form> </body>  

MVC controller shows a webservice internal call


I have a mvc controller that communicates with a we service for user authentication, when user clicks login button, onclick event makes a call to javascript function using ajax and it makes a call to an action in server.

The problem is when a use fiddler tool shows ajax call to the controller and also web service call, web service is called from controller never javascrit, how I can protect visibility of web service calling?, using web forms with the same scenario never shows a web service call.

How to call a webService Method Using Http get Protocol



I have Created A simple WebService Method Like If a Pass Id it will return Name Of the Employee from database.

That webService is Working Fine i ahve Tested It.

My Question is Now I haveto call this webservice using HttpGet Protocol from CLient Application.


please provide me some samples on it.




Thanks&Regards, -Amar.

Popupcontrol extender - webservice call failed 500


i have triws to use the Popupcontrol extender. But  I got the webservice call failed 500 error on the mouse over . i have referred the lots of forums, but i can't get the solutions...plz help me.


Herewith  i have specified the code.


                                    <asp:LinkButton ID="lb" runat="server" Text="TEST"></asp:LinkButton>
                                    <cc1:PopupControlExtender ID="pceImage" runat="server" DynamicServiceMethod="GetTheImage"

Is there any Sharepoint 2010 Webservice call that I can point my SSRS Report at to retrieve an execu


I want to create an SSRS report that displays all the steps in an executing workflow along with its current stage.

SharePoint 2010 webpart shows the current state of the executing workflow but I want to display all the steps including ones that have been completed and ones that are still to come.

how to call the Stored procedures dynamically


 hi frndz,

                 ringht now i am working with one web page, in that page

i have 3 sections of data [or 3 set of data]

in 1 set 4 to 5 fields

actions to be taken

when we click on save button

1st it should save the 1st fields data in one of my sp

and it should get the table level id

it should loop that table level id into another set of records & insert into to the another sp

same should be continued twice

pl some one help me


how to call a webservice upon opening form from library?



I have infopath forms in sharepoint library. When i open a submitted form, i want to call a webservice, how can i go about to achieve that?

What i have done so far is:

1. set a rule on a certain field

2. call the web service when that field gets populated

3. however, webservice is not called because my web service will output into a log file, but there's no output

C# following exception while reflection of dynamically created control.


ControlType = "System.Windows.Forms.WindowsFormsApplication1." + "PictureBox1"; System.Reflection.Assembly asm; asm = typeof(Form).Assembly; ControlObject = (System.Windows.Forms.Control)asm.CreateInstance(ControlType); ControlObject.Name = ControlName; The next code generated following exception for me: ControlObject.Name = ControlName;

NullReferenceException was unhandled Object reference not set to an instance of an object.

Dynamically Generate a WCF Proxy class at runtime and Callling web methods via reflection



I'm busy writing an application where the user will have to specify the location of a ?wsdl file for asmx and/or svc type services.

My application will have to :

1. Deduce from the wsdl what methods (with parameters and return types) are available on the service.

2. Provide a way to either generate a Proxy class in memory to execute methods against with e.g: Reflection

    for instanse : genericProxy.Invoke("HelloWorldMethod",parameter1,parameter2);

    I want to avoid using something like this : notSoGenericProxy.HelloWorldMethod(parameter1,parameter2); seeing that my application will have no 

    idea what service it will have to work with at runtime.

Is there a way to achieve this?

Thank you for any help in advance!

AJAX call to webservice is not working for strange reasons.


I have a webservice "DataService.asmx" which I am using for AJAX calls for insert, update, delete and some other tasks. All the pages are calling webservice smoothly but this new page I added and calling my webservice using the same ajax method not working. Strange thing is that neither its going on SUCCESS nor FAILURE...and put a breakpoint on my webservice but its not going into the webservice...plz help as its been 6 hours now figuring what the problem is..here is the code.

<script type="text/javascript">

    function UpdateBillRow(billingMonthObj, currentBillUnitsObj, bdueDateObj, AdvIncTaxObj, wHoldingTaxObj, gstObj, amtAfterDDObj, gRowID)
        var bmonth = document.getElementById(billingMonthObj).value;
        var currentunits = document.getElementById(currentBillUnitsObj).value;
        var duedate = document.getElementById(bdueDateObj).value;
        var advIncTax = document.getElementById(AdvIncTaxObj).value;
        var wTax = document.getElementById(wHoldingTaxObj).value;
        var gst = document.getElementById(gstObj).value;
        var amtafterdd = document.getElementById(amtAfterDDObj).value;
        var gridRowID = document.getElementById(gRowID);

        alert("button called and now going to call ajax...");

        //Call Ajax to check userid availability 

Problem with asynchronous call to webservice


Hello people.

I have a website where i call function in a web service. I am calling it asynchronously. The problem is the data which is returned from webservice is not shown in my label.

See here

protected void Page_Load(object sender, EventArgs e)
IAsyncResult asyncResult;

AsyncCallback callback = new AsyncCallback(MyCallBack);
asyncResult = serv.BeginGetImageList(req, callback, null);

private void MyCallBack(System.IAsyncResult asyncResult)

Label1.Text = "TEST";


Very simple but when the page is loaded, the label dont have any text.

Please help.

Enumerate all dll's and dynamically load them with REFLECTION


Hello guys,

Am trying out something new.


I want to

1. enumerate though the available dll files in a folder and using this code.

2. Dynamically load them with reflection


// GEt all the dll files


private const string dir =

Enumerate all dll's and dynamically load them with REFLECTION


Hello guys,

Am trying out something new.


I want to

1. enumerate though the available dll files in a folder and using this code.

2. Dynamically load them with reflection


// GEt all the dll files


private const string dir =

SOAP WebService Call error: The underlying connection was closed: A connection that was expected to


The underlying connection was closed: A connection that was expected to be kept alive was closed by the server..


We are trying to export some xml data to the client server using their web service, but we are receiving following exception

In some scenario when the connection take more than some expected time.


"The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.."


Problem Java call .NET webservice.


I created a very simple webservice (below)

namespace PmtCommu


    [WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 

    // [System.Web.Script.Services.ScriptService]

    public class PmoWebService : System.Web.Services.WebService



        public string PmoSvc_Test(string strVal)


            string retVal = string.Format("You sent me {0}.", strVal);

            // my code logging the strVal.

            return retVal;


I tested with .NET client. NO problem.

BUT, my service need to be consumed by Java client. I have trouble passing the parameter in.

I can see the "You sent me ." in my log and as a return value.

Following is the Java Code:


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend