Hello.
I'm missing something, I just know it.
I'm writing a web service and I'm new at this.
Scenario:
I got a Request and a Response XSD from a business partner. I used XSD.exe
to generate the C# classes.
I created a C# ASP Web Application. I added the generated classes to the
project. I then created a WebMethod whose return type is the generated
class that corresponds to the Response root element. I created variables for
each generated class, initialized each instance, and tried to to return the
"root" class instance (just to see if the XML generated corresponds to the
Response schema), but get an error. I posted the error in a previous
posting. Basically it looks like the runtime is compiling something, giving
it a random name, and then cannot find it.
So, at this point I don't know how to structure my project, I don't know
what the generated classes are good for (I thought I did) because based on
the error I'm misusing them, and I don't know how to return my user defined
class so that it corresponds to the schema.
Now, I've been all over MSDN, Googled, MSN Searched (Google is still better
at this point), went to Border's Books and read through everything they
have, and all I can find about WebServices are simple examples that return
"string, int, double". Really, nothing more than "Hello World" examples.
If "http://tempuri.org" is satisfactory for someone then it's no wonder
everyone says they're so simple to create. But that's not reality.
Where are the sample projects that show the structure of a solution that
does what I need to do? I know I'm not alone in the universe!
What am I missing? Do I need to use SOAP in some way?
Someone please point me in the right direction.
Thanks in advance,
Mike
DalePres - 04 Feb 2005 22:46 GMT
In ASP.Net, web services generally can only return value types and some
serializable object classes that Microsoft has chosen to implement the code
for. For instance, they can return a DataSet, because Microsoft implemented
it, but they cannot return a DataTable.
If you add an instance of the XMLInclude attribute to your return type class
and to each class that your return type references, that will often solve
the problem.
Hope this helps,
DalePres
MCAD, MCDBA, MCSE
> Hello.
>
[quoted text clipped - 39 lines]
>
> Mike
Dilip Krishnan - 04 Feb 2005 23:43 GMT
Hello DalePres,
I think what you're probably having a problem with is the return type
attributes... try using an attribute like this in your web method
[return : XmlElement("name-of-the-xml-element", Namespace="namespace-from-the-generated-class")]
[WebMethod]
public GeneratedClass SomeMethod()
{
return GeneratedClassInstance;
}
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
> In ASP.Net, web services generally can only return value types and
> some serializable object classes that Microsoft has chosen to
[quoted text clipped - 59 lines]
>>
>> Mike
Mike Lopez - 05 Feb 2005 15:10 GMT
Hi, Dilip. Thanks for responding.
Let me ask you, where is the documentation on the "[result:" attribute? I
cannot find it anywhere.
This is what I was talking about when I said "I know I'm missing something".
Thanks again,
Mike
> Hello DalePres,
> I think what you're probably having a problem with is the return type
[quoted text clipped - 77 lines]
>>>
>>> Mike
Dilip Krishnan - 05 Feb 2005 17:27 GMT
Hello Mike,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vcl
rfcsharpspec_17_2.asp
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
> Hi, Dilip. Thanks for responding.
>
[quoted text clipped - 88 lines]
>>>>
>>>> Mike
MikeL - 07 Feb 2005 13:41 GMT
Thanks Dilip. The mystery is gone.
Is there a VB.Net equivalent of these attributes?
Thanks again,
Mike
> Hello Mike,
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vcl
rfcsharpspec_17_2.asp
[quoted text clipped - 97 lines]
>>>>>
>>>>> Mike
Dilip Krishnan - 08 Feb 2005 04:28 GMT
Hello MikeL,
After the *As*
Public Function SomeFunction(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="http://someuri")>
ByVal SomeClass As someclass) As <System.Xml.Serialization.XmlElementAttribute("SomeReturn",
[Namespace]:="http://someuri")> SomeReturnType
End Function
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
> Thanks Dilip. The mystery is gone.
>
[quoted text clipped - 121 lines]
>>>>>>
>>>>>> Mike
Dan Rogers - 15 Feb 2005 22:44 GMT
I'm guessing after all of these responses, you're still stuck.
This not being able to find the compiled serializer tells me there's a
permissions problem. Did you change the identity or restrict the
permissions of the .NET runtime?
The XSD.exe tool already adds the appropriate markup to the generated
classes, so you don't have to do (usually) the XMLInclude and returns:
markup. That is used to serialze when no Xml*Attribute markup has been
added to the types you want to serialize.
--------------------
>Message-ID: <306392632434120830543216@msnews.microsoft.com>
>From: Dilip Krishnan <dkrishnan@NOSPAM.geniant.com>
[quoted text clipped - 9 lines]
>Lines: 1
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
.phx.gbl
>Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:28001
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>
[quoted text clipped - 3 lines]
>
>Public Function SomeFunction(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="htt
p://someuri")>
>ByVal SomeClass As someclass) As <System.Xml.Serialization.XmlElementAttribute("SomeReturn",
>[Namespace]:="http://someuri")> SomeReturnType
[quoted text clipped - 132 lines]
>>>>>>>
>>>>>>> Mike