By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

invoke a webservice with nillable value types

P: n/a
hi ng,

i try to invoke a webservice-method with an filter-object, that
contains value types. if i donīt want to filter the return value of
the method, i have to pass a new instance of the filter-object without
setting any properties. but the value type-properties canīt be null
and the filter is set to 0 (int) or false (bool).
therefore i did implement the propertySpecified-pattern like this:

[System.Xml.Serialization.SoapTypeAttribute("Search Criteria",
"http://criteria.xxx.yyy.zzz.de")]
public class SearchCriteria {

/// <remarks/>
public string matchcode;

/// <remarks/>
public string name;

/// <remarks/>
public int parteityp;

/// <remarks/>
[System.Xml.Serialization.SoapIgnore]
public bool parteitypSpecified;

/// <remarks/>
public bool aktiv;

/// <remarks/>
[System.Xml.Serialization.SoapIgnore]
public bool aktivSpecified;
}

1.question:
is it possible to autogenerate this pattern for nillable properties
with wsdl.exe (or similar), i had to do this manually.

2.question:
without the xxxSpecified-properties, the application works great, the
compiler doesnīt report any errors.
but with this Specified-pattern, an error occurs when instantiating
the service-object like this:

SearchCriteria mSearchCriteria = new SearchCriteria();
//here the error occurs
mFindBDService = new FindBDService();
objResult = mFindBDService.find(mSearchCriteria);

the error:
exception: System.IO.FileNotFoundException
msg: File- or Assemblyname '4t-43ufl.dll' or a dependency not found.
src: mscorlib

the name of dll changes at every call.

if i try to serialize the SearchCriteria-class beyond the
webservice-proxy, no error occurs. the xml-serializer works as
expected, the value types wonīt serialized if the
xxxSpecified-property is set to false, the xxxSecified-properties will
ignored by the xmlserializer.

i found only one thread in ng, that handles this problem, but without
solution:
http://groups.google.de/groups?hl=de...3DN%26tab%3Dwg

iīm running out of ideas, hope somebody can help!

regards,

stephan
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Stephan,

In general, it is not yet valid to pass nill XML values for value types.
It is supported to supress serialization of properties using the Specified
pattern, as you have uncovered.

The construct <xs:element name="foo" nillable="true" type="xs:int" /> is
not supported in the framework. The right way to encode this schema for
cross platform compatibility is <xs:element name="foo" minOccurs="0"
type="xs:int"/>. What this means is that the parameter is _optional_, but
not _nillable_.

If you use a tool such as XsdObjectGen.exe, then this optional pattern is
automatically generated for you from your schema - this assumes you start
with a schema however. If you are hand coding your classes, you have to
control the fooSpecified boolean yourself.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: ek****@web.de (stephan querengaesser)
Newsgroups: microsoft.public.dotnet.framework.webservices
Subject: invoke a webservice with nillable value types
Date: 1 Dec 2004 05:25:04 -0800
Organization: http://groups.google.com
Lines: 71
Message-ID: <37**************************@posting.google.com >
NNTP-Posting-Host: 217.80.170.162
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1101907505 8371 127.0.0.1 (1 Dec 2004 13:25:05
GMT)
X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Wed, 1 Dec 2004 13:25:05 +0000 (UTC)
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!news.glorb.com!postnews.google.com!not-for-mail
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7716
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

hi ng,

i try to invoke a webservice-method with an filter-object, that
contains value types. if i donīt want to filter the return value of
the method, i have to pass a new instance of the filter-object without
setting any properties. but the value type-properties canīt be null
and the filter is set to 0 (int) or false (bool).
therefore i did implement the propertySpecified-pattern like this:

[System.Xml.Serialization.SoapTypeAttribute("Search Criteria",
"http://criteria.xxx.yyy.zzz.de")]
public class SearchCriteria {

/// <remarks/>
public string matchcode;

/// <remarks/>
public string name;

/// <remarks/>
public int parteityp;

/// <remarks/>
[System.Xml.Serialization.SoapIgnore]
public bool parteitypSpecified;

/// <remarks/>
public bool aktiv;

/// <remarks/>
[System.Xml.Serialization.SoapIgnore]
public bool aktivSpecified;
}

1.question:
is it possible to autogenerate this pattern for nillable properties
with wsdl.exe (or similar), i had to do this manually.

2.question:
without the xxxSpecified-properties, the application works great, the
compiler doesnīt report any errors.
but with this Specified-pattern, an error occurs when instantiating
the service-object like this:

SearchCriteria mSearchCriteria = new SearchCriteria();
//here the error occurs
mFindBDService = new FindBDService();
objResult = mFindBDService.find(mSearchCriteria);

the error:
exception: System.IO.FileNotFoundException
msg: File- or Assemblyname '4t-43ufl.dll' or a dependency not found.
src: mscorlib

the name of dll changes at every call.

if i try to serialize the SearchCriteria-class beyond the
webservice-proxy, no error occurs. the xml-serializer works as
expected, the value types wonīt serialized if the
xxxSpecified-property is set to false, the xxxSecified-properties will
ignored by the xmlserializer.

i found only one thread in ng, that handles this problem, but without
solution:
http://groups.google.de/groups?hl=de...250430.5799334
f%40posting.google.com&rnum=1&prev=/groups%3Fq%3DCalling%2520a%2520web%2520s
ervice%2520with%2520nillable%2520Value%2520Types%2 6hl%3Dde%26lr%3D%26sa%3DN%
26tab%3Dwg

iīm running out of ideas, hope somebody can help!

regards,

stephan

Nov 21 '05 #2

P: n/a
hi dan,
thanks for your reply.
the problem still exists. please see below!
In general, it is not yet valid to pass nill XML values for value types.It is supported to supress serialization of properties using the Specifiedpattern, as you have uncovered.
iīm on the right way. ;-)
The construct <xs:element name="foo" nillable="true" type="xs:int" /> isnot supported in the framework. The right way to encode this schema forcross platform compatibility is <xs:element name="foo" minOccurs="0"
type="xs:int"/>. What this means is that the parameter is _optional_, butnot _nillable_.
If you use a tool such as XsdObjectGen.exe, then this optional pattern isautomatically generated for you from your schema - this assumes you startwith a schema however.


ifīve changed the schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ParteiSearchCriteria">
<xs:sequence>
<xs:element name="matchcode" minOccurs="0" type="xs:string"/>
<xs:element name="datum" minOccurs="0" type="xs:string"/>
<xs:element name="name" minOccurs="0" type="xs:string"/>
<xs:element name="parteityp" minOccurs="0" type="xs:int"/>
<xs:element name="aktiv" minOccurs="0" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
then iīve built this structure with your XsdObjectGen.exe. i`ve
swapped the structure with the old, mentioned in my first posting. the
structure is in the main-class of the webservice-proxy:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="FindBDImplSoapBinding",
Namespace="http://find.xxx.yy.zz")]
[System.Xml.Serialization.SoapIncludeAttribute(type of(ValidationError))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(BDfunctionException))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(VO))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(VOPage))]
public class FindBDImplService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

/// <summary>Zugriffspunkt des Webservices</summary>
public const string EndPoint =
"http://xx.yy.zz.services/FindBDImpl";
/// <remarks/>
public FindBDImplService() {
this.Url = EndPoint;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://find.xxx.yy.zz",
ResponseNamespace="http://find.xxx.yy.zz")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public VOPage find(ParteiSearchCriteria parteiSearch, int
offset, int limit) {
object[] results = this.Invoke("find", new object[] {
parteiSearch,
offset,
limit});
return ((ParteiVOPage)(results[0]));
}

[XmlType(TypeName="ParteiSearchCriteria"),XmlRoot,S erializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class ParteiSearchCriteria {

[XmlElement(ElementName="matchcode",IsNullable=true ,Form=XmlSchemaForm.Qualified,DataType="string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __matchcode;

[XmlIgnore]
public string matchcode {
get { return __matchcode; }
set { __matchcode = value; }
}

[XmlElement(ElementName="datum",IsNullable=true,For m=XmlSchemaForm.Qualified,DataType="string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __datum;

[XmlIgnore]
public string datum {
get { return __datum; }
set { __datum = value; }
}

[XmlElement(ElementName="name",IsNullable=true,Form =XmlSchemaForm.Qualified,DataType="string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __name;

[XmlIgnore]
public string name {
get { return __name; }
set { __name = value; }
}

[XmlElement(ElementName="parteityp",IsNullable=fals e,Form=XmlSchemaForm.Qualified,DataType="int")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public int __parteityp;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __parteitypSpecified;

[XmlIgnore]
public int parteityp {
get { return __parteityp; }
set { __parteityp = value; __parteitypSpecified = true; }
}

[XmlElement(ElementName="aktiv",IsNullable=false,Fo rm=XmlSchemaForm.Qualified,DataType="boolean")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktiv;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktivSpecified;

[XmlIgnore]
public bool aktiv {
get { return __aktiv; }
set { __aktiv = value; __aktivSpecified = true; }
}

public ParteiSearchCriteria() {
}
}

PROBLEM:
if i use the Specified-pattern, the instantiating of the
FindBDImplService failed with the error "File- or Assemblyname
'4t-43ufl.dll' or a dependency not found." (dll-name changes with
every call). i supposed a problem with serialization of this
main-class. if i test the serialization with XMLSerializer this throws
an exception due to a Site-property of the SoapHttpClientProtocol
because Site-property is an interface (not seralizable)?! if i test
serialization without Specified-pattern this error also occurs. but
the instantiating of the class FindBDImplService works fine and i can
invoke the find-method successfully.
maybe it is a problem with soap-serialization or soap-attributes?

BACKGROUND:
if i canīt serialize nullable values in ParteiSearchCriteria, i canīt
invoke the find-method without a filter. but i need to return
unfiltered results.

by the way, how can the server identificate the right property in the
autogenerated ParteiSearchCriteria, if this is XMLIgnore and the
serialized property is masked with "__"?
iīm finished, your reply could prevent me from jump out of the
window...

thanks for help!

regards,
stephan
Nov 21 '05 #3

P: n/a
Hi newsgroup, hi Dan,

thanks for your reply.
I did, what you suggested.
I generated the proxy-class with Specified-properties.
The next thing you want to do is change your web service implementation to
Document Literal style, instead of using the RPC style method. To do this
just remove the SoapRpcServiceAttribute that you added (this is not
necessary, and complicates what happens on the wire).


This is the solution: without RPC the serialization works without
System.IO.FileNotFoundException.

But your proceeding causes an error. The method will not identified as a
webservice-method.
So I changed the SoapRpcServiceAttribute to SoapDocumentMethodAttribute. The
request works now fine.

After that I have problems with soap-response. The soap-response for both
variants is equal. The RPC-variant returns filtered ParteiVOPage-object. But
the document-variant returns a null-reference as ParteiVOPage instead of
unfiltered ParteiVOPage. I only can see this in invoking methode:

mParteiVOPage = GetFindBDService().find(mParteiSC,Offset,Limit);

In the proxy-class I can't debug, breakpoints will ingnored. So I checked
the return-value of invoking-method.

I assume problems with interpreting soap-response. Maybe the
[return:]-attribute should be changed?!

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[] {
parteiSearch,
offset,
limit});
return ((ParteiVOPage)(results[0]));
}

I donīt have any ideas. hope you can help!
One more week with this problem and nobody can save me from being fired...
;-)

thanks and regards,
stephan
Nov 23 '05 #4

P: n/a
Hi Stephan,

Once you have properly converted the attributes (or take the defaults by
removing the SoapRpcService and SoapRpcMethod attributes), you will have
issues in the client unless the corresponding changes are made in the
generated proxy (or equivalent). The payload will be dramatically simpler
in the document literal case, so you need to make sure that you either
refresh the proxy used to call the web service (click on this in your
project, right click, refresh), or you can open the proxy code and make the
corresponding changes. You should see similar attributes to what you saw
on the service side.

I'm not sure what you mean by breakpoints ignored - this typically means
you set a breakpoint on a non-executable line of code, such as on a comment
or on an attribute. Debugging on the client can also be done readily by
setting a break point in the code that invokes the proxy, and step into the
proxy implementation.

If you are still seeing SoapElementAttribute, you will want to change the
proxy for sure - since that is expecting a SOAP encoded (section 5)
message. Think of it this way - proxy and service should match in the way
they are attributed.

Hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "stephan querengaesser" <ek****@web.de>
References: <37**************************@posting.google.com >
<1R**************@cpmsftngxa10.phx.gbl>
<37**************************@posting.google.com >
<Jn**************@cpmsftngxa10.phx.gbl>
Subject: Re: invoke a webservice with nillable value types
Date: Tue, 7 Dec 2004 16:25:16 +0100
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#u**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: pD4B9DE43.dip.t-dialin.net 212.185.222.67
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7949
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Hi newsgroup, hi Dan,

thanks for your reply.
I did, what you suggested.
I generated the proxy-class with Specified-properties.
The next thing you want to do is change your web service implementation to
Document Literal style, instead of using the RPC style method. To do this
just remove the SoapRpcServiceAttribute that you added (this is not
necessary, and complicates what happens on the wire).


This is the solution: without RPC the serialization works without
System.IO.FileNotFoundException.

But your proceeding causes an error. The method will not identified as a
webservice-method.
So I changed the SoapRpcServiceAttribute to SoapDocumentMethodAttribute.
The
request works now fine.

After that I have problems with soap-response. The soap-response for both
variants is equal. The RPC-variant returns filtered ParteiVOPage-object.
But
the document-variant returns a null-reference as ParteiVOPage instead of
unfiltered ParteiVOPage. I only can see this in invoking methode:

mParteiVOPage = GetFindBDService().find(mParteiSC,Offset,Limit);

In the proxy-class I can't debug, breakpoints will ingnored. So I checked
the return-value of invoking-method.

I assume problems with interpreting soap-response. Maybe the
[return:]-attribute should be changed?!

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[] {
parteiSearch,
offset,
limit});
return ((ParteiVOPage)(results[0]));
}

I donīt have any ideas. hope you can help!
One more week with this problem and nobody can save me from being fired...
;-)

thanks and regards,
stephan

Nov 23 '05 #5

P: n/a
Hi Dan,

I'm so sorry to bother you.
but the error still exists and it drives me crazy.
I try to explain the current situation. Please don`t be frightened of the
volume!

SUMMARY:

I want to invoke a webservice-method in an proxy-class, that needs a
filter-object as parameter.
If I want to pass nullable value-types as properties ot the filter-object, I
have to implement (manually or by XsdObjectGen) the Specified-properties
that corresponds to the value-type-properties, ok?

<code>
[XmlType(TypeName="ParteiSearchCriteria"),XmlRoot,S erializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class ParteiSearchCriteria {

[XmlElement(ElementName="aktiv",IsNullable=false,Fo rm=XmlSchemaForm.Qualified,DataType="boolean")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktiv;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktivSpecified;

[XmlIgnore]
public bool aktiv {
get { return __aktiv; }
set { __aktiv = value; __aktivSpecified = true; }
}

public ParteiSearchCriteria() {
}

}
</code>

Than I have to instantiate the webservice-proxy and filter-object and invoke
the method.
I was invoking the method in three way:

1.RPC-method (due to the wsdl)
<code>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>
While instantiating the webservice-proxy, an error occurs "File- or
Assemblyname '4t-43ufl.dll' or a dependency not found."
Iīve checked the autogenerated code in 4t-43ufl.0.cs. The compiler couldīt
build the dll due to this:

<code>
....
object rre = ReadReferencingElement(id24_boolean,
id4_httpwwww3org2001XMLSchema, out fixup.Ids[5]);
if (rre != null) {
try {
o.@__aktiv = (System.Boolean)rre;
}
catch (System.InvalidCastException) {
throw CreateInvalidCastException(typeof(System.Boolean), rre);
}
Referenced(o.@__aktiv);
}
= true; //<<<<-----THIS LINE OCCURS THE BUILD-ERROR
paramsRead[5] = true;
....
</code>
The same synthax-error occurs in the code of other value-typ-properties. Due
to this the compiler couldnīt build the dll.
You mentioned, I have to avoid RPC, so I did the 2nd way.

2.Document-method
<code>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>
If I configurate the attributes like this,no error occurs, the dll will
built, the soap-response is correct but the returned result-object is null.
I repeat: the soap ist correct, but it wonīt interpreted by the proxy.
Iīve read about configuration, that fix the problem with
SoapBindingUse.Encoded. So I tried the last way.

3.Document-method and SoapBindingUse.Encoded
<code>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de",Use=System.Web.Services.Descriptio n.SoapBindingUse.Encoded)]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>

Here the same error occurs like in point 1: "File- or Assemblyname
'randomxyz.dll' or a dependency not found."
<code>
....
Referenced(o.@__parteityp);
}
= true; //<<<<-----THIS LINE OCCURS THE BUILD-ERROR
paramsRead[3] = true;
....
</code>

Iīve got the notation that the reason is the code-generator of the
serializer.
It makes mistakes while serialization if I set Rpc or Encoded.
In order that you have all informations:

attributes of the webservice-class:
<webservice-class>
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="FindBDImplSoapBinding",
Namespace="http://xxx.yyy.zzz.de")]
[System.Xml.Serialization.SoapIncludeAttribute(type of(ValidationError))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(BDMalfunctionException))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(TokyoVO))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(TokyoVOPage))]
public class FindBDImplService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
....
}
</webservice-class>

soap-request with document-attribute and without value-type-properties
(point 2):

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body><find xmlns="http://xxx.yyy.zzz.de">
<parteiSearch>
<matchcode xsi:nil="true" />
<datum xsi:nil="true" />
<name xsi:nil="true" />
</parteiSearch>
<offset>0</offset>
<limit>99</limit>
</find>
</soap:Body>
</soap:Envelope>

unfiltered soap-response with document-attribute (point 2)
(...=abbreviated):

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:findResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://xxx.yyy.zzz.de">
<findReturn href="#id0"/>
</ns1:findResponse>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:ParteiVOPage"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://xxx.yyy.zzz.de">
<limit xsi:type="xsd:int">99</limit>
<offset xsi:type="xsd:int">0</offset>
<parteien xsi:type="soapenc:Array" soapenc:arrayType="ns2:ParteiVO[99]"
xmlns:ns3="http://xxx.yyy.zzz.de">
<item href="#id1"/>
...
<item href="#id33"/>
...
</parteien>
<size xsi:type="xsd:int">99</size>
<totalSize xsi:type="xsd:int">0</totalSize>
</multiRef>
...
<multiRef id="id33" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns4:ParteiVO" xmlns:ns4="http://xxx.yyy.zzz.de"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<active xsi:type="xsd:boolean">true</active>
<akid1 xsi:type="xsd:int">1</akid1>
<akid2 xsi:type="xsd:int">8</akid2>
<akid3 xsi:type="xsd:int">14</akid3>
<akid4 xsi:type="xsd:int">10</akid4>
<akid5 xsi:type="xsd:int">18</akid5>
<akid6 xsi:type="xsd:int">4</akid6>
<akid7 xsi:type="xsd:int">26</akid7>
<atid1 xsi:type="xsd:int">1</atid1>
<atid2 xsi:type="xsd:int">2</atid2>
<atid3 xsi:type="xsd:int">2</atid3>
<atid4 xsi:type="xsd:int">2</atid4>
<atid5 xsi:type="xsd:int">2</atid5>
<atid6 xsi:type="xsd:int">3</atid6>
<atid7 xsi:type="xsd:int">4</atid7>
<deleted xsi:type="xsd:boolean">false</deleted>
<kommentar xsi:type="xsd:string">Ach so is das</kommentar>
<matchcode1 xsi:type="xsd:string">musterfi00</matchcode1>
<matchcode2 xsi:type="xsd:string"></matchcode2>
<name1 xsi:type="xsd:string">Musterfirma</name1>
<name2 xsi:type="xsd:string">007</name2>
<ptid xsi:type="xsd:int">2</ptid>
<sid xsi:type="xsd:int">134</sid>
<tscr xsi:type="xsd:string">2003-11-19 15:48:00</tscr>
<tslc xsi:type="xsd:string">2003-12-22 12:31:14</tslc>
<tsmd xsi:type="xsd:string">2004-01-30 18:37:01</tsmd>
<ucr xsi:type="xsd:string">demo.gwo.admin</ucr>
<ulc xsi:type="xsd:string">demo.gwo.admin</ulc>
<umd xsi:type="xsd:string">locker bleiben</umd>
<vlc xsi:type="xsd:int">7</vlc>
</multiRef>
...
</soapenv:Body>
</soapenv:Envelope>
Answers to your question:
Once you have properly converted the attributes (or take the defaults by <removing the SoapRpcService and SoapRpcMethod attributes), you will haveissues in the client unless the corresponding changes are made in the
generated proxy (or equivalent). The payload will be dramatically simpler
in the document literal case, so you need to make sure that you either
refresh the proxy used to call the web service (click on this in your
project, right click, refresh),
If I refresh, the proxy will generated without Specified-properties.
or you can open the proxy code and make the
corresponding changes. You should see similar attributes to what you saw
on the service side.
I cantī see anything on server side. I have only the wsdl and the endpoint.

I'm not sure what you mean by breakpoints ignored - this typically means
you set a breakpoint on a non-executable line of code, such as on a comment
or on an attribute. Debugging on the client can also be done readily by
setting a break point in the code that invokes the proxy, and step into the
proxy implementation.
I canīt step into the proxy. I tried that, It doesnīt work. Breakpoints in
the proxy will be ignored.
If you are still seeing SoapElementAttribute, you will want to change the
proxy for sure - since that is expecting a SOAP encoded (section 5)
message. Think of it this way - proxy and service should match in the way
they are attributed.


The find-method in the wsdl is configured like this:
<wsdl:binding name="FindBDImplSoapBinding" type="impl:FindBDImpl">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="find">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="findRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://xxx.yyy.zzz.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="findResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://xxx.yyy.zzz.de" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

I donīt have other informations. note, that the soap-response with document
and rpc is the same. webservice seems to have no problems with that.
Dan, I hope, you are not at the end of the rope.
Itīs existential for me to pass nullable value-types in the filter-object to
webservice.
Otherwise my boss sharps the knife for my pelt...;-)

If you need more informations post or e-mail me!

Itīs good to know, there are experts out in the world, if you need
them...;-)
Thanks a lot for your help.

regards,
stephan
Nov 23 '05 #6

P: n/a
Hi Stephan,

You CANNOT pass null values for value types. What you have here is
optional values (via the specified code).

There are no adjustments you can make to the calling side code to correct
the need to get the interface workable on the service side. It isn't
reasonable to expect (from a cross platform perspective) the caller to be
able to pass null for value types, since the CLR doesn't support null for
value types. If someone has designed a service that needs null for value
types, it is very fair to say that the service was designed to only work
with Java or pure XML.

An option you do have is to work from the caller in pure XML and forgo the
serialization support.

I hope this helps

Dan
--------------------
From: "stephan querengaesser" <ek****@web.de>
References: <37**************************@posting.google.com >
<1R**************@cpmsftngxa10.phx.gbl>
<37**************************@posting.google.com >
<Jn**************@cpmsftngxa10.phx.gbl>
<#u**************@TK2MSFTNGP10.phx.gbl>
<7f*************@cpmsftngxa10.phx.gbl>
Subject: Re: invoke a webservice with nillable value types
Date: Wed, 8 Dec 2004 19:28:40 +0100
Lines: 312
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <Oz**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: pd950a56d.dip.t-dialin.net 217.80.165.109
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7984
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Hi Dan,

I'm so sorry to bother you.
but the error still exists and it drives me crazy.
I try to explain the current situation. Please don`t be frightened of the
volume!

SUMMARY:

I want to invoke a webservice-method in an proxy-class, that needs a
filter-object as parameter.
If I want to pass nullable value-types as properties ot the filter-object,
I
have to implement (manually or by XsdObjectGen) the Specified-properties
that corresponds to the value-type-properties, ok?

<code>
[XmlType(TypeName="ParteiSearchCriteria"),XmlRoot,S erializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class ParteiSearchCriteria {

[XmlElement(ElementName="aktiv",IsNullable=false,Fo rm=XmlSchemaForm.Qualifie
d,DataType="boolean")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktiv;

[XmlIgnore]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public bool __aktivSpecified;

[XmlIgnore]
public bool aktiv {
get { return __aktiv; }
set { __aktiv = value; __aktivSpecified = true; }
}

public ParteiSearchCriteria() {
}

}
</code>

Than I have to instantiate the webservice-proxy and filter-object and
invoke
the method.
I was invoking the method in three way:

1.RPC-method (due to the wsdl)
<code>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>
While instantiating the webservice-proxy, an error occurs "File- or
Assemblyname '4t-43ufl.dll' or a dependency not found."
Iīve checked the autogenerated code in 4t-43ufl.0.cs. The compiler couldīt
build the dll due to this:

<code>
...
object rre = ReadReferencingElement(id24_boolean,
id4_httpwwww3org2001XMLSchema, out fixup.Ids[5]);
if (rre != null) {
try {
o.@__aktiv = (System.Boolean)rre;
}
catch (System.InvalidCastException) {
throw CreateInvalidCastException(typeof(System.Boolean), rre);
}
Referenced(o.@__aktiv);
}
= true; //<<<<-----THIS LINE OCCURS THE BUILD-ERROR
paramsRead[5] = true;
...
</code>
The same synthax-error occurs in the code of other value-typ-properties.
Due
to this the compiler couldnīt build the dll.
You mentioned, I have to avoid RPC, so I did the 2nd way.

2.Document-method
<code>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de")]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>
If I configurate the attributes like this,no error occurs, the dll will
built, the soap-response is correct but the returned result-object is null.
I repeat: the soap ist correct, but it wonīt interpreted by the proxy.
Iīve read about configuration, that fix the problem with
SoapBindingUse.Encoded. So I tried the last way.

3.Document-method and SoapBindingUse.Encoded
<code>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="http://xxx.yyy.zzz.de",
ResponseNamespace="http://xxx.yyy.zzz.de",Use=System.Web.Services.Descriptio
n.SoapBindingUse.Encoded)]
[return: System.Xml.Serialization.SoapElementAttribute("fin dReturn")]
public ParteiVOPage find(ParteiSearchCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("find", new object[]
{parteiSearch,offset,limit});
return ((ParteiVOPage)(results[0]));
}
</code>

Here the same error occurs like in point 1: "File- or Assemblyname
'randomxyz.dll' or a dependency not found."
<code>
...
Referenced(o.@__parteityp);
}
= true; //<<<<-----THIS LINE OCCURS THE BUILD-ERROR
paramsRead[3] = true;
...
</code>

Iīve got the notation that the reason is the code-generator of the
serializer.
It makes mistakes while serialization if I set Rpc or Encoded.
In order that you have all informations:

attributes of the webservice-class:
<webservice-class>
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="FindBDImplSoapBinding"
,
Namespace="http://xxx.yyy.zzz.de")]
[System.Xml.Serialization.SoapIncludeAttribute(type of(ValidationError))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(BDMalfunctionException
))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(TokyoVO))]
[System.Xml.Serialization.SoapIncludeAttribute(type of(TokyoVOPage))]
public class FindBDImplService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
...
}
</webservice-class>

soap-request with document-attribute and without value-type-properties
(point 2):

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body><find xmlns="http://xxx.yyy.zzz.de">
<parteiSearch>
<matchcode xsi:nil="true" />
<datum xsi:nil="true" />
<name xsi:nil="true" />
</parteiSearch>
<offset>0</offset>
<limit>99</limit>
</find>
</soap:Body>
</soap:Envelope>

unfiltered soap-response with document-attribute (point 2)
(...=abbreviated):

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:findResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://xxx.yyy.zzz.de">
<findReturn href="#id0"/>
</ns1:findResponse>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:ParteiVOPage"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://xxx.yyy.zzz.de">
<limit xsi:type="xsd:int">99</limit>
<offset xsi:type="xsd:int">0</offset>
<parteien xsi:type="soapenc:Array" soapenc:arrayType="ns2:ParteiVO[99]"
xmlns:ns3="http://xxx.yyy.zzz.de">
<item href="#id1"/>
...
<item href="#id33"/>
...
</parteien>
<size xsi:type="xsd:int">99</size>
<totalSize xsi:type="xsd:int">0</totalSize>
</multiRef>
...
<multiRef id="id33" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns4:ParteiVO" xmlns:ns4="http://xxx.yyy.zzz.de"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<active xsi:type="xsd:boolean">true</active>
<akid1 xsi:type="xsd:int">1</akid1>
<akid2 xsi:type="xsd:int">8</akid2>
<akid3 xsi:type="xsd:int">14</akid3>
<akid4 xsi:type="xsd:int">10</akid4>
<akid5 xsi:type="xsd:int">18</akid5>
<akid6 xsi:type="xsd:int">4</akid6>
<akid7 xsi:type="xsd:int">26</akid7>
<atid1 xsi:type="xsd:int">1</atid1>
<atid2 xsi:type="xsd:int">2</atid2>
<atid3 xsi:type="xsd:int">2</atid3>
<atid4 xsi:type="xsd:int">2</atid4>
<atid5 xsi:type="xsd:int">2</atid5>
<atid6 xsi:type="xsd:int">3</atid6>
<atid7 xsi:type="xsd:int">4</atid7>
<deleted xsi:type="xsd:boolean">false</deleted>
<kommentar xsi:type="xsd:string">Ach so is das</kommentar>
<matchcode1 xsi:type="xsd:string">musterfi00</matchcode1>
<matchcode2 xsi:type="xsd:string"></matchcode2>
<name1 xsi:type="xsd:string">Musterfirma</name1>
<name2 xsi:type="xsd:string">007</name2>
<ptid xsi:type="xsd:int">2</ptid>
<sid xsi:type="xsd:int">134</sid>
<tscr xsi:type="xsd:string">2003-11-19 15:48:00</tscr>
<tslc xsi:type="xsd:string">2003-12-22 12:31:14</tslc>
<tsmd xsi:type="xsd:string">2004-01-30 18:37:01</tsmd>
<ucr xsi:type="xsd:string">demo.gwo.admin</ucr>
<ulc xsi:type="xsd:string">demo.gwo.admin</ulc>
<umd xsi:type="xsd:string">locker bleiben</umd>
<vlc xsi:type="xsd:int">7</vlc>
</multiRef>
...
</soapenv:Body>
</soapenv:Envelope>
Answers to your question:
Once you have properly converted the attributes (or take the defaults by <removing the SoapRpcService and SoapRpcMethod attributes), you will haveissues in the client unless the corresponding changes are made in the
generated proxy (or equivalent). The payload will be dramatically simpler
in the document literal case, so you need to make sure that you either
refresh the proxy used to call the web service (click on this in your
project, right click, refresh),
If I refresh, the proxy will generated without Specified-properties.
or you can open the proxy code and make the
corresponding changes. You should see similar attributes to what you saw
on the service side.
I cantī see anything on server side. I have only the wsdl and the endpoint.

I'm not sure what you mean by breakpoints ignored - this typically means
you set a breakpoint on a non-executable line of code, such as on a comment
or on an attribute. Debugging on the client can also be done readily by
setting a break point in the code that invokes the proxy, and step into the
proxy implementation.
I canīt step into the proxy. I tried that, It doesnīt work. Breakpoints in
the proxy will be ignored.
If you are still seeing SoapElementAttribute, you will want to change the
proxy for sure - since that is expecting a SOAP encoded (section 5)
message. Think of it this way - proxy and service should match in the way
they are attributed.


The find-method in the wsdl is configured like this:
<wsdl:binding name="FindBDImplSoapBinding" type="impl:FindBDImpl">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="find">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="findRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://xxx.yyy.zzz.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="findResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://xxx.yyy.zzz.de" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

I donīt have other informations. note, that the soap-response with document
and rpc is the same. webservice seems to have no problems with that.
Dan, I hope, you are not at the end of the rope.
Itīs existential for me to pass nullable value-types in the filter-object
to
webservice.
Otherwise my boss sharps the knife for my pelt...;-)

If you need more informations post or e-mail me!

Itīs good to know, there are experts out in the world, if you need
them...;-)
Thanks a lot for your help.

regards,
stephan

Nov 23 '05 #7

P: n/a
Hi Dan,
thanks for your reply.
You CANNOT pass null values for value types. What you have here is
optional values (via the specified code).
I have understood that since my first posting. ;-)
There are no adjustments you can make to the calling side code to correct
the need to get the interface workable on the service side. It isn't
reasonable to expect (from a cross platform perspective) the caller to be
able to pass null for value types, since the CLR doesn't support null for
value types. If someone has designed a service that needs null for value
types, it is very fair to say that the service was designed to only work
with Java or pure XML.
Youīre right. Thatīs the problem. The Webservice isn`t really interoperable.
An option you do have is to work from the caller in pure XML and forgot
the
serialization support.


Thatīs my solution. I`ve built my own serialization/deserialization for all
methods and objects that uses nullable value types. Now it works fine. The
rest works furthermore with the proxy.

Conclusion:
If I have to build an interoperable webservice I will substitute all value
types with strings. After transfer I will do the conversion back from string
to value types. I think that`s the best way, isnīt it?

Dan, thanks for your response. It was very helpful.
regards,

Stephan

Nov 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.