473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

invoke a webservice with nillable value types

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
7 5348
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jens | last post by:
Hello, i am trying to call a Apache WebService, which accepts NULL-Values for some Parameters of a specific Web-Method. NULL-Values are mapped within the soap-request by the .NET Client...
6
by: Markus Eßmayr | last post by:
Hello, I'd like to consume a WebService, which returns an array of objects which include several members of type System.String, System.Decimal and System.DateTime. In the WSDL-file, the members...
8
by: Marc | last post by:
Hi! I'm calling a web service using C# and a wrapper class generated by wsdl tool. The web service specification contains some nillable parameters which types are Value Types in .NET (long, int,...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
0
by: Chris Fink | last post by:
When I am consuming a webservice, an object has an undefined value (inq3Type.Call3Data). I do not completely understand why this is happening and apologize for the vague question. My assumption...
6
by: Sascha Schmidt | last post by:
Hi again! Well, the first part of my "mission" (calling remoting objects from a webservice) is solved. But there's another part: Calling this C#-Webservice from a java client. Is this a...
1
by: manfred | last post by:
Hi Together, I tried to build a webservice proxy using a wsdl, generated in the sun/java world. I used the .Net 2003 Version, choosing there VC++. The steps I did: 1. Visual C++ Projekte /...
1
by: Vishuonline | last post by:
Guys, I have had some experience in working with webservices created in .NET but this is the first time I am trying out one made in Java. When I run the wsdl exe to create a proxy class for...
1
by: gihan | last post by:
Hi, I have a problem accessing remote webservice from my asp code. Instead of returning results, it returns list of web methods it has. Wonder where i'm doing wrong. Also note that, this is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.