Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing Custom Types to and from Web Services

2 views
Skip to first unread message

Mark Duregon

unread,
Jan 31, 2003, 1:36:46 AM1/31/03
to
Hi,

We are having some difficulty with Web Service Proxy
classes, namespaces and custom data types. We have a web
based application that we have in the traditional 3 tier
model with web services in the middle tier providing the
business logic. We have defined our classes that are used
by the application in a Class Library. The application is
a very large application made up of various components and
is being developed by a number of various parties. We
have a namespace for the entire application (e.g.
MyNamespace) and have patitioned our area into another
namespace (e.g. MyNamespace.OurPart).

Now we did have the web services all in the same namespace
MyNamespace.OurPart.WebServices and generated a single
proxy class in the Web Forms using a disco file. This
casued problems with only the first Web Service in the
list actually being accessible. So we put each web service
into its own namespace
MyNameSpace.OurPart.Webservices.UserService and
MyNamepace.OurPart.Webservices.SecurityService for
example. This has meant that we are now able to have a
single proxy with multiple web services.

Our problem now is that we cannot pass back our custom
classes that we defined in our class library because we
get the following error when we try to compile the
solution:

Cannot convert from MyNamespace.OurPart.OurUser to
MyNamespace.OurPart.Web.UI.WebProxy.OurUser

We can get around this by removing the definition for
OurUser in the proxy class generated automatically by
Visual Studio but this seems like it is a hack and we get
the impression that we are not doing something correctly.

Are there some attribute(s) we need to define in the
[WebMethod] declaration or similar?

Is the "correct" procedure to actually delete the
automatically generated definitions for these classes from
the Reference.cs class every time we fresh the web service
to include new or updated web services?

Should we have a separate proxy for each Web Service?

Welcome any and all advice/experience.

Ciao,
Mark.

Christopher Jaynes

unread,
Jan 31, 2003, 11:04:02 AM1/31/03
to
Hi Mark,

Your problem is with the serialization of your classes into XML as they
traverse the web services.

As far as I know, you'll either have to use the proxy class that was created
by the web service on both ends of your application, or write a routine that
copies data in and out of the serializable proxy classes on both ends.

I would be careful if you are deleting the generated proxy classes, because
I wouldn't be sure how the data would be serialized, or if you would be
losing information in the process without the proxy class.

Hope that helps.

~Christopher


"Mark Duregon" <msdno...@aspect.com.au> wrote in message
news:05ef01c2c8f3$202d6810$d4f82ecf@TK2MSFTNGXA11...

Mike Moore [Microsoft]

unread,
Jan 31, 2003, 6:33:15 PM1/31/03
to
Hi Mark,

We're looking into your question. We don't have any information for you
immediately. We expect to have something for you by Tuesday.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>From: "Christopher Jaynes" <cja...@thatchertech.com>
>References: <05ef01c2c8f3$202d6810$d4f82ecf@TK2MSFTNGXA11>
>Subject: Re: Passing Custom Types to and from Web Services
>Date: Fri, 31 Jan 2003 10:04:02 -0600
>Lines: 74
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
>Message-ID: <ukUQTJUyCHA.2592@TK2MSFTNGP10>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
>NNTP-Posting-Host: 65.196.215.226
>Path: cpmsftngxa08!cppssbbsa01.microsoft.com!TK2MSFTNGP08!TK2MSFTNGP10
>Xref: cpmsftngxa08
microsoft.public.dotnet.framework.aspnet.webservices:15120
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Mike Moore [Microsoft]

unread,
Feb 5, 2003, 2:22:47 PM2/5/03
to
Hi Mark,

I apologize for the delay. I had found someone to work on your issue, but I
just found out that he went home sick after I spoke with him and he hasn't
returned yet. I'm looking for another person to research your question.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>X-Tomcat-ID: 839684778
>References: <05ef01c2c8f3$202d6810$d4f82ecf@TK2MSFTNGXA11>
<ukUQTJUyCHA.2592@TK2MSFTNGP10>
>MIME-Version: 1.0
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: mic...@online.microsoft.com ("Mike Moore [Microsoft]")
>Organization: Microsoft
>Date: Fri, 31 Jan 2003 23:33:15 GMT


>Subject: Re: Passing Custom Types to and from Web Services

>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>Message-ID: <YTQQXEYyCHA.2492@cpmsftngxa08>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
>Lines: 101
>NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182
>Path: cpmsftngxa06!cpmsftngxa08
>Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webservices:15050

Wade Mascia [MS]

unread,
Feb 6, 2003, 3:37:01 PM2/6/03
to
Hi Mark,

If you search for posts from me on this newsgroup, you'll find a few posts
to different threads on this topic. The problem is not related to your
namespace scheme; this is expected behavior even in the simplest of cases.
When you add a web reference, your client will build a skeleton class
definition for any custom types that are to be sent to\fro the webservice -
this is the class definition that you find in your reference.vb\cs file.
If the client happens to have a reference to a dll where this type is
truely defined, then you can simply delete the skeleton class definition
from the reference.xx file and the object will be deserialized into the
appropriate type instead of the skeleton type. Note you typically need to
add an import\using at the top of the reference.xx file so it knows where
to get the class def. from.

HTH!

~Wade Mascia, MCSD
Developer Support Engineer - WebServices, EnterpriseServices, MTS,
COM+, ASP/COM
 Microsoft Corporation

And now, a word from our lawyers: "This posting is provided 'AS IS' with

no warranties, and confers no rights."
--------------------

| X-Tomcat-ID: 496194223
| References: <05ef01c2c8f3$202d6810$d4f82ecf@TK2MSFTNGXA11>
<ukUQTJUyCHA.2592@TK2MSFTNGP10> <YTQQXEYyCHA.2492@cpmsftngxa08>


| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: mic...@online.microsoft.com ("Mike Moore [Microsoft]")
| Organization: Microsoft

| Date: Wed, 05 Feb 2003 19:22:47 GMT


| Subject: Re: Passing Custom Types to and from Web Services
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

| Message-ID: <zq82rvUzCHA.1796@cpmsftngxa08>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| Lines: 132
| NNTP-Posting-Host: TOMCATIMPORT3 10.201.220.210
| Path: cpmsftngxa06!cpmsftngxa10!cpmsftngxa08
| Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webservices:15157

Mark Duregon

unread,
Feb 6, 2003, 8:36:23 PM2/6/03
to
Thanks Wade,

That helps. It makes sense but we just wanted to make sure
we were doing it correctly and there wasn't an
easier/other more correct way of doing this and weren't
doing more work than we had to and then find out 6 months
down the track there was some feature in VS or the
framework that did all this for us.

Thanks for your help.

Ciao,
Mark.

>.
>

Brian Smith

unread,
Feb 7, 2003, 5:51:00 AM2/7/03
to
Wow! This really p***es me off, having spent two days restructuring my
code and adding conditional compilation sections to change the namespace
for my typed DataSets.

How safe is your approach? Presumably the references.cs file will stay
unchanged unless you call Update Web Reference. Not entirely happy about
this - surely MS could have provided a more intelligent generator to
exclude such definitions if they are already provided by another
reference. Any changes in 1.1?

brian

In article <wdBnA#hzCHA.2068@cpmsftngxa06>, wma...@online.microsoft.com

Wade Mascia [MS]

unread,
Feb 7, 2003, 4:10:17 PM2/7/03
to
I do understand what you're saying. The problem is that the .wsdl is
NET-agnostic so it will not mention anything like namespaces. So when you
add the web reference it has no clue what the original namespace was for
MyObject. So the only thing it could do is enumerate all references to
find a class named "MyObject" but there'd be no gaurantee that it's the
right object, there could be many "MyObject"'s in different namespaces,
etc. Sticking .NET-specific into the .wsdl is a bad idea w.r.t. interop,
so VS.NET assumes the typical case and creates the client-side reference
for you. HTH!!

~Wade Mascia, MCSD
Developer Support Engineer - WebServices, EnterpriseServices, MTS,
COM+, ASP/COM
 Microsoft Corporation

And now, a word from our lawyers: "This posting is provided 'AS IS' with
no warranties, and confers no rights."
--------------------

| From: bsm...@leazes.com (Brian Smith)
| Reply-To: bsm...@leazes.com


| Subject: Re: Passing Custom Types to and from Web Services

| Date: Fri, 7 Feb 2003 10:51 +0000 (GMT Standard Time)
| Message-ID: <memo.2003020...@leazes.com>
| References: <wdBnA#hzCHA.2068@cpmsftngxa06>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| NNTP-Posting-Host: userdc015.dsl.pipex.com 62.190.226.15
| Lines: 1
| Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP12
| Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webservices:15224
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Markus Reding

unread,
Feb 10, 2003, 9:32:40 AM2/10/03
to

Hallo

I have a similar problem. In my Webservice i defined just the the base
Type. (Webmethod (Kontextbase kontext).

On the Client i wannt to pass an inherited Type from Kontextbase to the
Webservice. If i try this, the Error (There was an error generating the
XML document.) appears.


How can i imlement this?

Thanks for any help

Mac


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Markus Reding

unread,
Feb 10, 2003, 10:21:19 AM2/10/03
to

Hallo Mr. Mascia

I’ve got a problem passing custom Types to a Method of a Webservice.

Definitions:

I’ve got a base class ‘Kontextbase’ and one from KontextBase inherited
class ‘KontextApp’. Both of these Types are defined in a separate
Assembly with the Namespace Kontexts.

On the Webservice I defined an Method: public dsLibs
GetAvaiableLibs(KontextBase kontext) {…}

On the Client I have something like this:

KontextApp kontext = new KontextApp(); // KontextApp is inherited from
Kontextbase


kontext.ID = 1;

kontext.SelectionID =”pers1”;


// get all libs who are available in this App-Kontext.
dsLibs ds = mywebserviceinstance.GetAvaiableLibs (kontext);

If I run the code follow Runtime-Error appears: ‘There was an error
generating the XML document.’

The code works, if I just pass an Object from Type ‘Kontextbase’ to the
Webservice, if I do the changes in the references.cs. (Deleting Skeleton
of KontextBase and implement the using-definitions.)

How can I pass an Object from Type ‘KontextApp’?

I hope you can help me

Cu

Wade Mascia [MS]

unread,
Feb 11, 2003, 9:56:16 AM2/11/03
to
You can use XmlInclude...

[XmlInclude(typeof(CDerived))]
public class CBase
{
//...
}


Or you can use XmlElement...

[WebMethod]
public void ReceiveBaseClass([XmlElement(typeof(CDerived))] CBase b)
{
//...
}

HTH!

~Wade Mascia, MCSD
Developer Support Engineer - WebServices, EnterpriseServices, MTS,
COM+, ASP/COM
 Microsoft Corporation

And now, a word from our lawyers: "This posting is provided 'AS IS' with
no warranties, and confers no rights."
--------------------

| From: Markus Reding <m...@devigus.com>
| References: <wdBnA#hzCHA.2068@cpmsftngxa06>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)


| Subject: Re: Passing Custom Types to and from Web Services

| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <#dHQFFR0CHA.1644@TK2MSFTNGP12>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| Date: Mon, 10 Feb 2003 06:32:40 -0800
| NNTP-Posting-Host: actionjackson37.dsl.frii.net 216.17.146.37


| Lines: 1
| Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP12
| Xref: cpmsftngxa06

microsoft.public.dotnet.framework.aspnet.webservices:15268
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

0 new messages