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.d e>
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.publi c.dotnet.framew ork.webservices
NNTP-Posting-Host: pd950a56d.dip.t-dialin.net 217.80.165.109
Path:
cpmsftngxa10.ph x.gbl!TK2MSFTFE ED01.phx.gbl!TK 2MSFTNGP08.phx. gbl!TK2MSFTNGP1 5
.phx.gbl
Xref: cpmsftngxa10.ph x.gbl
microsoft.publi c.dotnet.framew ork.webservices :7984
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(TypeNam e="ParteiSearch Criteria"),XmlR oot,Serializabl e]
[EditorBrowsable (EditorBrowsabl eState.Advanced )]
public class ParteiSearchCri teria {
[XmlElement(Elem entName="aktiv" ,IsNullable=fal se,Form=XmlSche maForm.Qualifie
d,DataType="boo lean")]
[EditorBrowsable (EditorBrowsabl eState.Advanced )]
public bool __aktiv;
[XmlIgnore]
[EditorBrowsable (EditorBrowsabl eState.Advanced )]
public bool __aktivSpecifie d;
[XmlIgnore]
public bool aktiv {
get { return __aktiv; }
set { __aktiv = value; __aktivSpecifie d = true; }
}
public ParteiSearchCri teria() {
}
}
</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.Serv ices.Protocols. SoapRpcMethodAt tribute("",
RequestNamespac e="http://xxx.yyy.zzz.de" ,
ResponseNamespa ce="http://xxx.yyy.zzz.de" )]
[return: System.Xml.Seri alization.SoapE lementAttribute ("findReturn ")]
public ParteiVOPage find(ParteiSear chCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("fi nd", new object[]
{parteiSearch,o ffset,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 = ReadReferencing Element(id24_bo olean,
id4_httpwwww3or g2001XMLSchema, out fixup.Ids[5]);
if (rre != null) {
try {
o.@__aktiv = (System.Boolean )rre;
}
catch (System.Invalid CastException) {
throw CreateInvalidCa stException(typ eof(System.Bool ean), 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.Serv ices.Protocols. SoapDocumentMet hodAttribute("" ,
RequestNamespac e="http://xxx.yyy.zzz.de" ,
ResponseNamespa ce="http://xxx.yyy.zzz.de" )]
[return: System.Xml.Seri alization.SoapE lementAttribute ("findReturn ")]
public ParteiVOPage find(ParteiSear chCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("fi nd", new object[]
{parteiSearch,o ffset,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.Serv ices.Protocols. SoapDocumentMet hodAttribute("" ,
RequestNamespac e="http://xxx.yyy.zzz.de" ,
ResponseNamespa ce="http://xxx.yyy.zzz.de" ,Use=System.Web .Services.Descr iptio
n.SoapBindingUs e.Encoded)]
[return: System.Xml.Seri alization.SoapE lementAttribute ("findReturn ")]
public ParteiVOPage find(ParteiSear chCriteria parteiSearch, int offset, int
limit) {
object[] results = this.Invoke("fi nd", new object[]
{parteiSearch,o ffset,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.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Web.Serv ices.WebService BindingAttribut e(Name="FindBDI mplSoapBinding"
,
Namespace="http ://xxx.yyy.zzz.de" )]
[System.Xml.Seri alization.SoapI ncludeAttribute (typeof(Validat ionError))]
[System.Xml.Seri alization.SoapI ncludeAttribute (typeof(BDMalfu nctionException
))]
[System.Xml.Seri alization.SoapI ncludeAttribute (typeof(TokyoVO ))]
[System.Xml.Seri alization.SoapI ncludeAttribute (typeof(TokyoVO Page))]
public class FindBDImplServi ce :
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {
...
}
</webservice-class>
soap-request with document-attribute and without value-type-properties
(point 2):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<soap:Body><fin d 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)
(...=abbreviate d):
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelo pe 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:findRespon se
soapenv:encodin gStyle="http://schemas.xmlsoap .org/soap/encoding/"
xmlns:ns1="http ://xxx.yyy.zzz.de" >
<findReturn href="#id0"/>
</ns1:findRespons e>
<multiRef id="id0" soapenc:root="0 "
soapenv:encodin gStyle="http://schemas.xmlsoap .org/soap/encoding/"
xsi:type="ns2:P arteiVOPage"
xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/"
xmlns:ns2="http ://xxx.yyy.zzz.de" >
<limit xsi:type="xsd:i nt">99</limit>
<offset xsi:type="xsd:i nt">0</offset>
<parteien xsi:type="soape nc:Array" soapenc:arrayTy pe="ns2:ParteiV O[99]"
xmlns:ns3="http ://xxx.yyy.zzz.de" >
<item href="#id1"/>
...
<item href="#id33"/>
...
</parteien>
<size xsi:type="xsd:i nt">99</size>
<totalSize xsi:type="xsd:i nt">0</totalSize>
</multiRef>
...
<multiRef id="id33" soapenc:root="0 "
soapenv:encodin gStyle="http://schemas.xmlsoap .org/soap/encoding/"
xsi:type="ns4:P arteiVO" xmlns:ns4="http ://xxx.yyy.zzz.de"
xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/">
<active xsi:type="xsd:b oolean">true</active>
<akid1 xsi:type="xsd:i nt">1</akid1>
<akid2 xsi:type="xsd:i nt">8</akid2>
<akid3 xsi:type="xsd:i nt">14</akid3>
<akid4 xsi:type="xsd:i nt">10</akid4>
<akid5 xsi:type="xsd:i nt">18</akid5>
<akid6 xsi:type="xsd:i nt">4</akid6>
<akid7 xsi:type="xsd:i nt">26</akid7>
<atid1 xsi:type="xsd:i nt">1</atid1>
<atid2 xsi:type="xsd:i nt">2</atid2>
<atid3 xsi:type="xsd:i nt">2</atid3>
<atid4 xsi:type="xsd:i nt">2</atid4>
<atid5 xsi:type="xsd:i nt">2</atid5>
<atid6 xsi:type="xsd:i nt">3</atid6>
<atid7 xsi:type="xsd:i nt">4</atid7>
<deleted xsi:type="xsd:b oolean">false</deleted>
<kommentar xsi:type="xsd:s tring">Ach so is das</kommentar>
<matchcode1 xsi:type="xsd:s tring">musterfi 00</matchcode1>
<matchcode2 xsi:type="xsd:s tring"></matchcode2>
<name1 xsi:type="xsd:s tring">Musterfi rma</name1>
<name2 xsi:type="xsd:s tring">007</name2>
<ptid xsi:type="xsd:i nt">2</ptid>
<sid xsi:type="xsd:i nt">134</sid>
<tscr xsi:type="xsd:s tring">2003-11-19 15:48:00</tscr>
<tslc xsi:type="xsd:s tring">2003-12-22 12:31:14</tslc>
<tsmd xsi:type="xsd:s tring">2004-01-30 18:37:01</tsmd>
<ucr xsi:type="xsd:s tring">demo.gwo .admin</ucr>
<ulc xsi:type="xsd:s tring">demo.gwo .admin</ulc>
<umd xsi:type="xsd:s tring">locker bleiben</umd>
<vlc xsi:type="xsd:i nt">7</vlc>
</multiRef>
...
</soapenv:Body>
</soapenv:Envelop e>
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
correspondin g 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 SoapElementAttr ibute, 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="FindBDImp lSoapBinding" type="impl:Find BDImpl">
<wsdlsoap:bindi ng style="rpc"
transport="http ://schemas.xmlsoap .org/soap/http"/>
<wsdl:operati on name="find">
<wsdlsoap:opera tion soapAction=""/>
<wsdl:input name="findReque st">
<wsdlsoap:bod y
encodingStyle=" http://schemas.xmlsoap .org/soap/encoding/"
namespace="http ://xxx.yyy.zzz.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="findRespo nse">
<wsdlsoap:bod y
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