System.InvalidOperationException Every Time I try a particular Web Reference

Greetings Fellow J# Developers!

I am currently working on a project which requires me to make references to the Autodesk Vault Web API.  This API apparantly at some point passes in an array of INTS or LONGS.  Although I cannot post the code from their end (on account it is closed source), I can post my code that is generating the error (though I don't feel it will be of any help).  I posted this to the Autodesk Vault user group, and this is the reply that I got:

Reply From: Doug Redmond \(Autodesk\)
Date: Jul/25/05 - 12:27 (GMT)

Reply
    Re: GetLatestFileAssociationsByMasterIds can not be reflected.
This looks to be a bug in that way J# handles web services. Apparently J#
can't handle web service functions where arrays of longs or ints are passed
in.
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx id=234947

I suggest creating a C# or VB.NET project to generate the web references.
Your J# projects can then reference those objects.


Doug Redmond
Software Engineer, Autodesk Inc.

The code I posted for him to look at is below:



public boolean loginNow(String userName, String Password, String Vault )

{

/**

* Open the security service... logging in as administrator, for now

*

*/

SignIn.SecurityService thisService = new SignIn.SecurityService();

try

{

thisService.SignIn(userNam e ,Password, Vault ) ;

}

catch(System.Web.Services.Protocols.SoapException f)

{

return false;

}

/**

* Instantiate a new Instance of the Document Service.

*/

MessageBox.Show(this, "TEST1" ) ;


this.thisService2 = new Document.DocumentServiceWse();

Although I was skeptical at first about the plausability of such a horrible horrible hole, I tried the same methods in C# and it worked perfectly.  Can someone from Microsoft, or someone with more experience in J# Confirm this   Thank You ... 

Alexandros "Aleksei" Nipirakis




Answer this question

System.InvalidOperationException Every Time I try a particular Web Reference

  • mix600

    Hi,
    Thanks for unearthing the issue. We have already fixed this issue and it no longer repros on our internal builds. You won't hit it again on VS2005.

    Thanks.

  • amckern

    Hi Jaiprakash,

    Your code worked for me as well....

    I have spoken and worked with Autodesk, and the problem has been nailed down.  It seems the behavior I am seeing is produced only when a function uses a Enumeration of XML Attributes . Is there a known issue with J# not being able to handle Enumerations of XML Attributes   And if so, is this problem resolved (or will it be resolved) in .net 2005  

    If you use the following class in a C# web services project, and then try to instantiate that class.. it should fail.  It will give you an identitcal error as the one that I have been getting before.

    BTW... If you need to get ahold of me this evening (it appears as though you are on the forums about 20.30 PST) Please contact me at my email anipirakis <AT> tmail.com .  I can answer any questions you may have quicker that way.

    Here is the code:



    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Serialization;

    namespace testServer
    {
        /// <summary>
        /// Summary description for Service1.
        /// </summary>
        public class Service1 : System.Web.Services.WebService
        {
            public Service1()
            {
                //CODEGEN: This call is required by the ASP.NET Web Services Designer
                InitializeComponent();
            }

            #region Component Designer generated code
           
            //Required by the Web Services Designer
            private IContainer components = null;
                   
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                if(disposing && components != null)
                {
                    components.Dispose();
                }
                base.Dispose(disposing);       
            }
           
            #endregion


            [WebMethod]
            public EnumObject EnumTest()
            {
                return new EnumObject();
            }
        }

        public enum TypeEnum
        {
            Thing1 = 0,
            Thing2 = 1
        }

        public class EnumObject
        {
            [XmlAttribute (AttributeName="Typ")]
            public TypeEnum Type = TypeEnum.Thing1;

            public EnumObject ()
            {   }
        }
    }



     



    Be sure to reference the Microsoft.Web.Services2 package.


    Thank You  very much for your time and effort..

    Alexandros "Aleksei" Nipirakis



  • zuninet

    just wondering what the final answer to this one is...

    Thanks
    Aleksei



  • Michel Baladi

    Hi,
    Sorry for the delay. We are looking into this and it will take 1 or 2 days more to give you concrete information.

    Thanks for your patience.


  • Federico Kolliker Frers - MSFT

    Hi,
    Thanks alot for your detailed response. It will be helpful in isolating the issue. Actually you are working on Visual Studio 2003 and last time I checked it on Visual Studio 2005 Beta2. Therefore I  couldn't hit the issue. Let us check on VS2003. We will get back to you as early as possible.

    Thanks for your patience.

  • DLeighty

    Alex: did you remember to thank your super IT Ops team for providing you with the software Big Smile
    Laurie K


  • zainta

    Hi,
    I tried to repro it on VS2003. I created a C# web service and referred it in a J# console application. C# web service has following 3 methods...

    [WebMethod]
    public int[] PassAndReturnIntArray(int [] intArr)
    {
    return intArr;
    }

    [WebMethod]
    public float[] PassAndReturnfloatArray(float [] floatArr)
    {
    return floatArr;
    }

    [WebMethod]
    public float[] PassIntFloatReturnfloatArray(float [] floatArr, int [] intArr)
    {
    return floatArr;
    }

    J# console app refers this web service and calls these methods one by one...

    CSWeb.Service1 serv1 = new Service1();
    float [] floatArr = serv1.PassAndReturnfloatArray(new float[] {(float)1.2, (float)1.4});
    int [] intArr = serv1.PassAndReturnIntArray(new int[] {3, 60});
    float [] floatArr2 = serv1.PassIntFloatReturnfloatArray(new float[] {(float)1.2, (float)1.4}, new int[] {3, 60});

    Here CSWeb is reference name i chose while referring the service.

    This console app runs fine for me, i am not getting any exception at all. Can you please try this simple repro on you machine and see if it repros.

    One more thing, have you made sure that reference to service is correct. You can check this by updating the web reference (right click on reference node in solution explorere and click "update web reference".)

    Apart from this, is this possible for me to refer the same web service which you are trying to refer to if yes then please let me know how can i do that

    Just FYI, if there is some problem with the arguments being passed, then System.InvaliArgumentException must be thrown. InvalidOPerationException is thrown when a method call is invalid for the object's current state.

    Thanks.




  • Andrew MacNeill

    Thank you very much for the reply.  I cannot wait to see your next post about this subject.

    Thank you

    Aleksei



  • Spidey

    I am sure i did :)

    Aleksei



  • Sudheesh Suresh

    Thanks for your reply,  I will attempt to answer the questions you have posed as best as I can:

    1. I am using Visual Studio J# Version 7.1.3088 2003 .net ( I am sure that I completly mangled your version naming :) ) 
    2. I am not sure what language the webservice was written in, I looked at the DocumentService.asmx file that was on the server ( which I assume to be some sort of  a header file for Microsoft Web Services, though to be brutally honest, I have no idea what I am doing with the Server Side portion of Web Services, as I usually implement my web services of this nature in pure Java). This is what I saw inside the asmx file:

    <%@ WebService Language="c#" Codebehind="DocumentService.asmx.cs" Class="Connectivity.Web.Services.DocumentService" %>

    I believe this means that it was originally written in C#.

    3.  I am using a no argument constructor, the constructur inside the webreference on my machine looks like this:
        /** <remarks/> */
        public DocumentServiceWse() {
            this.set_Url("http://XXSERVERXX/AutodeskDM/Services/DocumentService.asmx");
        }

    The place it is saying it cannot reflect is:
        /** <remarks/> */
        /** @attribute System.Web.Services.Protocols.SoapHeaderAttribute("SecurityHeaderValue")*/
        /** @attribute System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://AutodeskDM/Services/Document/01/21/2005/GetLatestFileAssociationsByMasterI" +
    "ds", RequestNamespace="http://AutodeskDM/Services/Document/01/21/2005/", ResponseNamespace="http://AutodeskDM/Services/Document/01/21/2005/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)*/
        public FileAssocArray[] GetLatestFileAssociationsByMasterIds(long[] fileMasterIds, AssociationRelationEnum relation, boolean recurse) {
            Object[] results = this.Invoke("GetLatestFileAssociationsByMasterIds", new Object[] {
                        fileMasterIds,
                        relation,
                        (System.Boolean)recurse}
            );
            return ((FileAssocArray[])(results[0]));
        }

    4. Unfortunately, I don't have a clue what their code is doing, but as I said, all I am doing is trying to instantiate an instance of a WSE object using J# with a zero argument constructor.  The same exact code that I am using in J# seems to work in C# (with a few minor changes in syntax) which leads me to believe that there is some difference between the two languages.  The only reason I said anything about the arrays is that the Autodesk Programmer suggested that this might be a cause of the problem.


    Finally, I suppose it might be helpful to post the actual exception text... sorry for not originally doing this:


    An unhandled exception of type 'System.InvalidOperationException' occurred in system.web.services.dll

    Additional information: Method DocumentServiceWse.GetLatestFileAssociationsByMasterIds can not be reflected.



    Again, thank you in advance for any light you can shead on this situation.  I appreciate your dilligance in this matter.

    Alexandros "Aleksei" Nipirakis
    G&T Conveyor Tavares, Fl


  • Ian1971

    Hi,
    I tried this on my machine but everything works fine for me. What I tried is that I have a C# web service which has a function which takes an array of Integers and returns the array of integers.
    i referrd this web service in my J# project and called the function. This worked fine for me.

    Apart from this, this scenario passed for following combination of WebService - Client also...

    1. J# Service - J# client
    2. ATL Service - J# client

    So I am little doubtful about any bug on this with us. Can you please answer following questions to get your scenario better..

    1. Which version of J#/Visual Studio are you working on
    2. Which language the referred Web Service has been written in, if you can find out. (though it hardly matters on .net).
    3. The prototype of the function which throws this exception.
    4. Are you doing proper typecating for sending and receiving the values

    Thanks.

  • SuburbanDriver

    Hi Jaiprakash,

    Would it be possible to create a service pack for those of us not upgrading to 2005   My company just recently purchased a brand new 2003 License for me because we needed the dev environment before 2005 would be released.  I think that it would only be fair for you to release such changes to those of us that are using 2003 products in the way of a hot fix or service pack.

    Thanks
    Alexandros A Nipirakis



  • System.InvalidOperationException Every Time I try a particular Web Reference