Mar 7, 2008 at 5:52 AM
Edited Mar 7, 2008 at 6:00 AM
Wondering which is the best way to dynamically invoking a webservice. We have been using Dynwslib (available at http://www.thinktecture.com/Resources/Software/DynWsLib/default.html) and running into some issues with invoking remote URLs (works fine on localhost).
We are getting the System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Client found response content type of '', but expected 'text/xml'. exception
Dynwslib uses the following line of code to invoke the web service dynamically
MethodInfo mi = proxyInstance.GetType().GetMethod(methodName);
object paramsArray = (object)methodParams.ToArray(typeof(object))
object result = mi.Invoke(proxyInstance, paramsArray); //Line throwing the exception
Please see below for additional details
I have been using the Dynwslib for my asp.net application (version 1.5). We are still on asp.net 1.1/VS 2003.
The Dynwslib has been mostly working. We have been using the dll to access Webservices/ methods dynamically. Everything seems to be working fine on our local server (IIS 6.0, Windows 2003 server). We can access the WSDL from an external site using IE.
I recently posted the web service to my external server and wrote a small sample app to consuming it using Dynwslib. When I consume it using localhost everything works fine. However when I give the static IP, the behavior is inconsistent. Somethimes I get the
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Client found response content type of '', but expected 'text/xml'.
This is being thrown by the
object result = mi.Invoke(proxyInstance, paramsArray); call in the InvokeCall() method. I am not specifying any namespace in my webservice, could that be a problem? Appreciate any help on this.
Here is the sample calling code
private void Button1_Click(object sender, System.EventArgs e)
string sDisplayStateRequest= "Test value";
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
string sWebServiceURL = "http://www.domainname.com/ServiceConnector.asmx?WSDL";
ws.WSDL = sWebServiceURL;
string sTypeName = "SC";
ws.TypeName = sTypeName;
ws.MethodName = "GetInfo";
//This parameter is used to call another method of a web service by the GetInfo method
object oGetDisplayState = ws.InvokeCall(); //line trowing exception
string sRetVal = (string)oGetDisplayState;
Thanks in Advance