473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Library differences when adding Web Reference

Here's what happens: I got a Web Service installed locally on my IIS. Then I got a client project, which will call this service. But when I add the Web Reference to the Web Service, and look at the imported classes with Object Browser, there are classes missing. How can that be?

The classes in question are of course public, and I see them in Object Browser in the Web Service project. The classes are auto-generated from an XSD file, using the xsd.exe tool (but that shouldn't matter).

Gustaf
Jun 29 '07 #1
5 1955
"Gustaf" <gu*****@algonet.sewrote in message
news:e7**************@TK2MSFTNGP04.phx.gbl...
Here's what happens: I got a Web Service installed locally on my IIS. Then
I got a client project, which will call this service. But when I add the
Web Reference to the Web Service, and look at the imported classes with
Object Browser, there are classes missing. How can that be?

The classes in question are of course public, and I see them in Object
Browser in the Web Service project. The classes are auto-generated from an
XSD file, using the xsd.exe tool (but that shouldn't matter).
What kind of classes are missing? For instance, are SOAP Fault classes
missing? If so, that's because .NET ignores SOAP Faults as far as processing
a WSDL is concerned.
--
John Saunders [MVP]

Jun 29 '07 #2
John Saunders [MVP] wrote:
What kind of classes are missing? For instance, are SOAP Fault classes
missing? If so, that's because .NET ignores SOAP Faults as far as
processing a WSDL is concerned.
Thanks for helping. The one class I see is missing, is the class that corresponds to the root element type in the schema. I noticed that only complex types get their class representations when generating code with xsd.exe, not element declarations. So, in this case

<xs:element name="MyRoot" type="MyRootType"/>

<xs:complexType name="MyRootType">
<xs:sequence>
<xs:element name="MyItem" type="MyItemType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

there is no MyRoot class generated, but a MyRootType class. In my case, it's the MyRootType class that's missing when I import the classes using a Web Reference.

Gustaf
Jul 2 '07 #3
"Gustaf" <gu*****@algonet.sewrote in message
news:uM**************@TK2MSFTNGP05.phx.gbl...
John Saunders [MVP] wrote:
>What kind of classes are missing? For instance, are SOAP Fault classes
missing? If so, that's because .NET ignores SOAP Faults as far as
processing a WSDL is concerned.

Thanks for helping. The one class I see is missing, is the class that
corresponds to the root element type in the schema. I noticed that only
complex types get their class representations when generating code with
xsd.exe, not element declarations. So, in this case

<xs:element name="MyRoot" type="MyRootType"/>

<xs:complexType name="MyRootType">
<xs:sequence>
<xs:element name="MyItem" type="MyItemType"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

there is no MyRoot class generated, but a MyRootType class. In my case,
it's the MyRootType class that's missing when I import the classes using a
Web Reference.
Do you use the MyRootType directly? Does your Web Reference code compile?

I've noticed that XSD.EXE will only include types it thinks are being used,
and this isn't always the same set of types you think are being used. In one
case, I had to play around for days to get it to include the types I wanted.

As an experiment, could you add a web method that returns a MyRoot and then
see what that generates in the Web Reference?
--
John Saunders [MVP]

Jul 2 '07 #4
John Saunders [MVP] wrote:
Do you use the MyRootType directly? Does your Web Reference code compile?
I can set up the Web Reference without complaints, so I suppose that part is okay as far as Visual Studio is concerned. The Web Service project compiles, and if I check Object Browser from that project, I see all the classes I want. Then when I include the Web Reference to this Web Service from another project, one class disappears.
I've noticed that XSD.EXE will only include types it thinks are being
used, and this isn't always the same set of types you think are being
used. In one case, I had to play around for days to get it to include
the types I wanted.
I noticed that too. If you include an element with no parent in the schema, it's not represented in the generated code. Naturally, the root element has no parent, but the class for the root element type is indeed generated (with the XmlRootAttribute attribute), and is recognized in the Web Service project.

So it appears to me that whatever happens, happens when setting up the Web Reference.
As an experiment, could you add a web method that returns a MyRoot and
then see what that generates in the Web Reference?
It generates a method with a return value of the class one level below the root element. But nevemind that now. After so much time spent on this, I had to stop working on it. Thanks anyway.

Gustaf
Jul 4 '07 #5
John Saunders [MVP] wrote:
I'd like to create a reproducer for this, because I can see it as an
issue that will come up for many developers. Unfortunately, I'm tied up
at the moment and may not get to it in the next couple of days.
I have now simplified the schema and stripped it from all sensitive information, so I can make it public here, for you and others to test. I have also tested that the schema produces the result described. Here's the schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns="http://example.org/Response"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/Response"
elementFormDefault="qualified">

<xs:complexType name="ResponseType">
<xs:sequence>
<xs:element name="ErrorCode" type="xs:string"/>
<xs:element name="ErrorMessage" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="ResponseListType">
<xs:sequence>
<xs:element name="Response" type="ResponseType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:element name="ResponseList" type="ResponseListType"/>

</xs:schema>

And here's step-by-step instruction on how you produce the same error:

1. Generate a file with classes from the schema with the xsd.exe tool.
2. Create a new Web Service project, and import the generated file.
3. Add a WebMethod that returns a ResponseListType object:

[WebMethod]
public ResponseListType GetResponseList() {
return null;
}

4. Using Object Browser, confirm that the ResponseListType class is included. It is.
5. Create a Console Application project and add a web reference to the web service.
6. Using Object Browser, look for the ResponseListType class among the classes imported by the web reference. It won't be there.

Gustaf


Jul 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
2
by: Lady_A | last post by:
Hi, I need to add a reference to a static library (*.lib) to a COM/ATL project in VS.NET. Apparently if this library is not in my solution that is not possible using the ordinary way : Add...
2
by: Zippy | last post by:
Some months ago, we requested help from this newsgroup on how to replace the library reference of a database with another library reference, prior to creating an MDE. I got the following answer...
16
by: Randy Yates | last post by:
I have an Access database that has been running fine on multiple platforms (Windows 2000, Windows XP, etc.) for several years. Recently, the database has begun to issue "Run-Time Error 2467" on...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
4
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
3
by: S S | last post by:
Hi Are there some known issues using STL with shared library. Recently I got some crash for which the reason I dont see any, and searching on goolge shown some such issues with shared library. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.