invalid operation exception

Hi,
I'm very new to this and I would appreciate any help you might be able to give me.

I am building a composite web service on my local machine. This web service is to be comprised of calls to two other web services, one on my local machine and one not.

The web service I am trying to incorporate into the composite web service retrieves data from an SQLServer database. It tests fine; when I use a web application to test it, it also works fine.

However, when I try to call it from the composite web service, it throws an invalid operation exception. I have set the credentials of the instance of the proxy class in the composite web method to:

System.Net.CredentialCache.DefaultCredentials

This solved my problem when I was testing it with a client; it did not help me when I tried to invoke a method in the composite web service.

Again, any help would be greatly appreciated.
Thanks,
Ivy

[946 byte] By [ivycress] at [2008-2-4]
# 1
This normally happens when web services infrastructure could not deserilize your SOAP messages and reflect it to one of your webmethod.
Normally refresh the web reference to keep it up to date with the server's web service will solve the problem.
erymuzuan at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2
Hi,
Thanks very much for your response. However, I tried updating the web reference and it is still throwing the invalid operation exception. Do you have any other suggestions?
Thanks in advance,
Ivy
ivycress at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3
Hi,
I was also wondering if there is some type of clean up I should be doing when I catch the exception; presently, my function returns a string to let me know which exception was thrown. However, it does something to my internet connection which renders it unusable. When I try to repair it, or try to send my browser to another page, the entire os freezes and I have to manually restart. I have been doing this for days and it is driving me crazy. Any help is greatly appreciated.
Thanks,
Ivy
ivycress at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 4
Did you try to run it on different machine, there might be something with your connection, may be a firewall or proxy that has modified the SOAP message.

May be you could post your code, up here .. I mean if you don't mind , and the steps to reproduce the problems

erymuzuan at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 5
Hi, I'd be glad to post my code.

This works fine:

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

REM I deleted this part for posting

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getAlcRestTest.Click

REM get the quote from the web service

Dim result As String

Dim dset As New localhost.getAlcRestDS

' Dim stockSymbol As String

'stockSymbol = symbolInput.Text

Dim webRef As localhost.morgFinalDB

webRef = New localhost.morgFinalDB

webRef.Credentials = System.Net.CredentialCache.DefaultCredentials

dset = webRef.getAlcRest

result = dset.ToString

TextBox1.Text = result

REM display the results in a text box

End Sub

End Class
The following does NOT work; you will see that I tried to catch a lot of exceptions before I found the one it is throwing.

<WebMethod()> _

Public Function morgTest() As String

Dim result As String

result = "success"

REM put everything concerning the web

REM service call in a try-catch block

Try

Dim dset As New localhost.getAlcRestDS

Dim webRef As localhost.morgFinalDB

webRef = New localhost.morgFinalDB

webRef.Credentials = System.Net.CredentialCache.DefaultCredentials

REM getAlcRest returns a dataset of type localhost.getAlcRestDS
REM This is also the line that is causing the exception to be thrown,
REM although it works fine in the windows form.

dset = webRef.getAlcRest()

REM I tried to catch every possible exception

REM until the web method came back with an exception

REM that would give me a clue as to what

REM was causing it to not work

Catch ex As System.Security.SecurityException
Return Nothing
Catch ex As SyntaxErrorException
Return "syntax"
Catch ex As DataException
Return "data exception"
Catch ex As EvaluateException
Return "evaluate exception"
Catch ex As ApplicationException
Return "application exception"
Catch ex As AppDomainUnloadedException
Return "app domain unloaded"
Catch ex As ArgumentException
Return "argument"
Catch ex As ArgumentNullException
Return "argument null"
Catch ex As ArgumentOutOfRangeException
Return "arg out of range"
Catch ex As ArithmeticException
Return "arithmetic"
Catch ex As ArrayTypeMismatchException
Return "array type mismatch"
Catch ex As CannotUnloadAppDomainException
Return "cannot unload app domain"
Catch ex As ConstraintException
Return "constraint"
Catch ex As ContextMarshalException
Return "context marchall"
Catch ex As DataException
Return "data exception"
Catch ex As DBConcurrencyException
Return "db concurrency"
Catch ex As DeletedRowInaccessibleException
Return "deleted row inaccessible"
Catch ex As DivideByZeroException
Return "div by 0"
Catch ex As DllNotFoundException
Return "dll not found"
Catch ex As DuplicateNameException
Return "duplicate name"
Catch ex As DuplicateWaitObjectException
Return "duplicate wait object"
Catch ex As EntryPointNotFoundException
Return "entry pt not found"
Catch ex As EvaluateException
Return "evaluate"
Catch ex As ExecutionEngineException
Return "exec engine"
Catch ex As FieldAccessException
Return "field access"
Catch ex As FormatException
Return "format"
Catch ex As HttpCompileException
Return "http compile"
Catch ex As HttpException
Return "http"
Catch ex As HttpParseException
Return "http parse"
Catch ex As HttpRequestValidationException
Return "http request validation"
Catch ex As HttpUnhandledException
Return "http unhandled e"
Catch ex As IndexOutOfRangeException
Return "index out of range"
Catch ex As InRowChangingEventException
Return "in row changing"
Catch ex As InvalidCastException
Return "invalid cast"
Catch ex As InvalidConstraintException
Return "inv constraint"
Catch ex As InvalidExpressionException
Return "inv expression"
Catch ex As InvalidExpressionException
Return "invalid expr"


REM this is this exception it is throwing
Catch
ex As InvalidOperationException
Return "INVALID OPERATION - THIS IS THE ONE IT'S THROWING"

Catch ex As InvalidProgramException
Return "inv prog"
Catch ex As IO.EndOfStreamException
Return "io.eos"
Catch ex As MemberAccessException
Return "member access"
Catch ex As MethodAccessException
Return "method access"
Catch ex As MissingPrimaryKeyException
Return "miss pk"
Catch ex As MissingFieldException
Return "miss field"
Catch ex As MissingMethodException
Return "miss method"
Catch ex As MulticastNotSupportedException
Return "multicast"
Catch ex As NoNullAllowedException
Return "no null"
Catch ex As NotFiniteNumberException
Return "not finite"
Catch ex As NotImplementedException
Return "not implemented"
Catch ex As NotSupportedException
Return "not supported"
Catch ex As NullReferenceException
Return "null ref"
Catch ex As ObjectDisposedException
Return "obj disposed"
Catch ex As Odbc.OdbcException
Return "odbc"
Catch ex As OleDb.OleDbException
Return "oledb"
Catch ex As OutOfMemoryException
Return "out of mem"
Catch ex As OverflowException
Return "overflow"
Catch ex As PlatformNotSupportedException
Return "plat not supported"
Catch ex As Protocols.SoapException
Return "proto soap"
Catch ex As Protocols.SoapHeaderException
Return "proto soap head"
Catch ex As RankException
Return "rank"
Catch ex As ReadOnlyException
Return "read only"
Catch ex As Reflection.AmbiguousMatchException
Return "refl abig match"
Catch ex As Reflection.CustomAttributeFormatException
Return "refl cust att form"
Catch ex As Reflection.InvalidFilterCriteriaException
Return "refl invalid filter criteria"
Catch ex As Reflection.ReflectionTypeLoadException
Return "refl refl type load"
Catch ex As Reflection.TargetException
Return "refl target exception"
Catch ex As Reflection.TargetInvocationException
Return "refl target invocation
Catch ex As Reflection.TargetParameterCountException
Return "refl target param count"
Catch ex As SqlTypes.SqlNullValueException
Return "sql types sql null value"
Catch ex As SqlTypes.SqlTruncateException
Return "sql types sql truncate"
Catch ex As SqlTypes.SqlTypeException
Return "sql types sql type"
Catch ex As Exception
Return "haven't found it yet"

End Try

Return result

End Function

Any ideas? Thanks again,
Ivy

ivycress at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 6
Hi,

I forgot to include the steps to reproduce the error, but I'm not sure they will be of help. To reproduce the error, I simply try to debug in Visual Studio .NET. The methods I call from the webservice (localhost.morgFinalDB) retrieve data from an SQL Server database. I was hoping that the credentials would solve my problem, and they did for the windows app (just not the composite web service).

I don't know if this will shed any light on the matter, but when I run the windows app (which works), I get a request from my firewall about it accessing the internet. However, I get no notification when I try to make the call from the composite web service.

Thanks,
Ivy

ivycress at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 7
Theoritacally there's nothing wrong with the code, (though a better way to try to diagnose the exception, is by using, HttpApplication OnError, or use excetion.GeType().Fullame property).
My assumption would be your web service application is not correctly configured, so the 1st place is the IIS virtual directory security settings( and if necessary re-register aspnet script ,aspnet_regiis -i ), and the 2nd place is your web.config, take a look at the authorization section.

BTW, try to disable the firewall temporarily, or give aspnet worker process the authorization, and your web.config file just have the minimum information as possible. Then remove the credential bit from your code. see what happen.

erymuzuan at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 8
Sorry, I had a family emergency and just got back home.
I think my problem is that I know nothing about how to configure my web service application. Can you point me to a resource that can help me learn how to do this? Thanks in advance,
~Ivy
ivycress at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 9
there are many places where you can dig this, the 1st one is MSDN Web Service Site and MSDN ASP.Net, well the .Net web services is built on top of ASP.Net.

Another great resource is WSE.

erymuzuan at 2007-9-8 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified