Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / January 2006

Tip: Looking for answers? Try searching our database.

Problem with VS Web Reference to document-literal style web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Desmond Fitzgerald - 18 Jan 2006 11:20 GMT
We have a document-literal style web service that we provide to a number
of external parties.

The input is a create applicant request document with some structured
customer details including xs:date and bool elements.

The problem occurs when we add a web reference to this service and try
to invoke it using the generated proxies. The serialized request is
missing some of the elements.

When I looked further into this it seems that the generated classes in
Reference.cs have a number of xxxSpecified properties and fields
corresponding to members such as date of births and some of the boolean
flags.

However, when you set the DOB field, for example, it does not set the
DOBSpecified flag to true. Then it appears that XMLSerializer will not
serialize the associated property.

I am using XSDObjectGen to generate the server-side classes and these do
not exhibit the same problem. They set the xxxSpecified flags correctly.
The java tools I have tried also process the WSDL correctly and there is
nothing wrong with the Schema.

Obviously, I have a number of options to fix the client side proxies
such as:

1. Rewrite the Reference.cs in terms of the XSDObjectGen classes.
2. Add statements to Reference.cs to set the specified flags properly.

The problem is that some of our clients will be using VS and it is
highly inconvenient to have them do this every time they update the Web
Reference.

To help them I could:

* Provide a script that does (2) above.
* Provide a class that introspects the request at run-time and sets the
specified flags properly.

Again, I would rather not have to do this. Having to kludge things like
this is making the RPC style look attractive again!

Does anyone know how I can sort this out properly. It seems like a bug
in wsdl.exe?
Josh Twist - 18 Jan 2006 12:05 GMT
In the past I've known people to hand-craft proxies for web services
and provide them as SDK's to clients. This is an opportunity to make
the proxies more user friendly with collections instead of arrays
etc... a real shame that VS is struggling with your WSDL though...

Which version of Visual Studio are you using? Is the web service
written in .NET?
Desmond Fitzgerald - 18 Jan 2006 12:26 GMT
That is definitely an option. Actually the XSDObjectGen generated
proxies are quite a bit more friendly that those produced by WSDL.exe.
So that could be a good start.

What I don't understand is why it creates xxxSpecified properties for
some elements and not others. There doesn't seem to be any obvious logic
behind it.
Josh Twist - 18 Jan 2006 14:28 GMT
I'm afraid I'm not sure what you mean by 'xxxSpecified' properties? Can
you elaborate?
Desmond Fitzgerald - 18 Jan 2006 14:51 GMT
WSDL.exe generates partial classes such as the following excerpt. If the
DobSpecified property is set to false then the serializer seems to skip
over serializing the Dob property. It won't be present in the serialized
XML representation even if object is created and the property is set.

Now, it is set to false by initialization and is never set even if the
setter of Dob is used. This is in contrast to classes generated by
XSDObjectGen which set the DobSpecified flag to true if the setter is
used.

I can fix the Reference.cs by inserting a statement such as DobSpecified
= true; on every setter of properties with matching xxxSpecified
properties but this is irratating at best.

   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml",
"2.0.50727.42")]
   [System.SerializableAttribute()]
   [System.Diagnostics.DebuggerStepThroughAttribute()]
   [System.ComponentModel.DesignerCategoryAttribute("code")]
   public partial class personalDetailsType {
             
       // ...

       private System.DateTime dobField;
       private bool dobFieldSpecified;
       
       // ...

       [System.Xml.Serialization.XmlElementAttribute(DataType="date")]
       public System.DateTime Dob {
           get {
               return this.dobField;
           }
           set {
               this.dobField = value; this.DobSpecified = true;
           }
       }
       
       [System.Xml.Serialization.XmlIgnoreAttribute()]
       public bool DobSpecified {
           get {
               return this.dobFieldSpecified;
           }
           set {
               this.dobFieldSpecified = value;
           }
       }

       // ...

   }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.