Error calling BEA WebLogic WS from VB.NET
I'm getting an error trying to call a WS. I setup the web reference in VS.NET (2003 Enterprise) and the tool does not complain.
All my code is doing at this point is attempting to instantiate the object:
Dim myws as New eDataFeed
This comes back and fails with the message:
System.InvalidOperationException: Method eDataFeed.getBusLmpByType can not be reflected. > System.InvalidOperationException: The XML element named 'collectionNodeLmp' from namespace 'http://temp.openuri.org/schemas/eDataFeed.xsd' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.
I've done a comple of Google searches and can't come up with any good suggestions as to what this error actually means - much less how to fix it.
All ideas apreciated.
Thanks,
Matt
This exception means that there appears to be a name clash in the WSDL file. There is a method and a type in the WSDL that have the same name and namespace. You can try resolving the name clash using the attributes specified if you control the server.
This is potentially a bug. Add Web Reference should never generate a proxy type that fails at construction time.
Please post the WSDL file and the failing proxy code so that we can investigate this issue. I also recommend upgrading to VS 2005 to see if this issue still exists.
Daniel Roth
Hi Matt,
This is very similar to a problem I've found a way to solve. It appears to be a bug unique to "Add Web Reference" for Visual Studio.NET, and within Visual Studio, only Visual Basic. It seems to have been fixed in VS 2008's "Add Service Reference".
If you get an InvalidOperationException on the line where you create the service as an object (Dim myservice As New WebServiceX) and end up with error messages like these in the details:
{"Method WebServiceX.MethodName can not be reflected."}
{"There was an error reflecting 'MinorObject1'."}
{"The XML element 'MinorObject' from namespace 'http://serviceXsite' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element."}
Then try doing this:
Look to the Solution Explorer box at the top right. Choose the option to show all files. Click on the + signs to expand the problem Web Reference (in this example WebServiceX, in your case eDataFeed) and then within that, expand the Resources.vb file. This is the "stub" file that .NET automatically creates for you to use the web service, and is included in your project automatically. There is a bug in this file.
Look for the Public Function for the method from your problem (in this example MethodName, in your case getBusLmpByType) and then look along its parameters. Somewhere along there is a string in the XML properties for the problem object (in this example MinorObject, in your case collectionNodeLmp) along with another parameter for another such object, but without a string.
The offending parameters might look like this:
ByVal MinorObject As WebServiceX_MinorQQQObj, <System.Xml.Serialization.XmlElementAttribute("MinorObject", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>
ByRef MinorObject1 As WebServiceX_MinorRRRObj, <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>
(Or in your case, getBusLmpByType instead of MinorObject.)
Delete the string to make the two <System.XML....Unqualified> tags look the same. That should solve the problem. There may be other strings in the parameters - leave those as they are.
After this, the project should run. To be safe, it's a good idea to copy, paste, and comment out this line of code in case this is NOT the correct solution and things only get worse. :)
The bug occurs because two objects of almost (but not) the same type in the same method were interpreted by VB to occupy the same namespace, and so VB's stub generator gave itself a bug that it couldn't solve. This problem only seems to affect VB.NET "Add Web Reference" (not even C#.NET "Add Web Reference", just the VB) and it has been corrected in the new VS 2008 version of "Add Web Reference", called "Add Service Reference".
I hope this solves your problem! If anyone comes along with a variation on this problem, please post it and (I hope) your solution.