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