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

D

Desmond Fitzgerald

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?
 
J

Josh Twist

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?
 
D

Desmond Fitzgerald

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.
 
J

Josh Twist

I'm afraid I'm not sure what you mean by 'xxxSpecified' properties? Can
you elaborate?
 
D

Desmond Fitzgerald

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;
}
}

// ...

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top