HighTechTalks DotNet Forums  

Trouble with complex return types

Dotnet Framework (Webservices) microsoft.public.dotnet.framework.webservices


Discuss Trouble with complex return types in the Dotnet Framework (Webservices) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sebastian.mattar@gmail.com
 
Posts: n/a

Default Trouble with complex return types - 01-02-2008 , 06:11 AM






HI there!

I am trying to consume a web service implemented in Perl (SOAP::Lite)
using VS Express 2008. I already implemented a client in java without
problems.

I succeeded in calling the web service, but the SOAP-Call returns a
complex type which is not handled correctly.
Invoke() throws an exception stating that an object of type
system.String can not be assigned to type RetDataType. Debugging shows
that the deserializer seems to handle the first return variable only
(string), ignoring the second (int), completely unaware of the complex
return type.

I would be glad if anybody could give me a hint.

Excerpt from WSDL-proxy:
-------------------
/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://temp.de/aPOTs", ResponseNamespace="http://
temp.de/aPOTs")]
[return:
System.Xml.Serialization.SoapElementAttribute("mak ePDFReturn")]
public RetDataType makePDF(string type, string result,
[System.Xml.Serialization.SoapElementAttribute(Data Type="base64Binary")]
byte[] data) {
object[] results = this.Invoke("makePDF", new object[] {
type,
result,
data}); // THROWS EXCEPTION!
return (RetDataType)(results[0]);
}


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.SoapTypeAttribute(Namespa ce="http://temp.de/
aPOTs")]
public partial class RetDataType {

private string refidField;
private System.Nullable<int> eetField;

/// <remarks/>
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public string refid {
get { return this.refidField; }
set { this.refidField = value; }
}

/// <remarks/>
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public System.Nullable<int> eet {
get { return this.eetField; }
set { this.eetField = value; }
}
}
------------------------

Captured SOAP-Response:
-----------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" soap:encodingStyle="http://
schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<makePDFResponse xmlns="http://temp.de/aPOTs">
<refid xsi:type="xsd:string">qAmkBf5OxL.1199270773</refid>
<eet xsi:type="xsd:int">5</eet>
</makePDFResponse>
</soap:Body>
</soap:Envelope>
--------------------------

Best regards,
Sebastian

Reply With Quote
  #2  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Trouble with complex return types - 01-02-2008 , 09:33 AM






<sebastian.mattar (AT) gmail (DOT) com> wrote

Quote:
HI there!

I am trying to consume a web service implemented in Perl (SOAP::Lite)
using VS Express 2008. I already implemented a client in java without
problems.

I succeeded in calling the web service, but the SOAP-Call returns a
complex type which is not handled correctly.
Invoke() throws an exception stating that an object of type
system.String can not be assigned to type RetDataType. Debugging shows
that the deserializer seems to handle the first return variable only
(string), ignoring the second (int), completely unaware of the complex
return type.

I would be glad if anybody could give me a hint.

Excerpt from WSDL-proxy:
-------------------
/// <remarks/
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://temp.de/aPOTs", ResponseNamespace="http://
temp.de/aPOTs")]
[return:
System.Xml.Serialization.SoapElementAttribute("mak ePDFReturn")]
public RetDataType makePDF(string type, string result,
[System.Xml.Serialization.SoapElementAttribute(Data Type="base64Binary")]
byte[] data) {
object[] results = this.Invoke("makePDF", new object[] {
type,
result,
data}); // THROWS EXCEPTION!
return (RetDataType)(results[0]);
}


/// <remarks/
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.SoapTypeAttribute(Namespa ce="http://temp.de/
aPOTs")]
public partial class RetDataType {

private string refidField;
private System.Nullable<int> eetField;

/// <remarks/
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public string refid {
get { return this.refidField; }
set { this.refidField = value; }
}

/// <remarks/
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public System.Nullable<int> eet {
get { return this.eetField; }
set { this.eetField = value; }
}
}
------------------------

Captured SOAP-Response:
-----------------------
soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" soap:encodingStyle="http://
schemas.xmlsoap.org/soap/encoding/"
soap:Body
makePDFResponse xmlns="http://temp.de/aPOTs"
refid xsi:type="xsd:string">qAmkBf5OxL.1199270773</refid
eet xsi:type="xsd:int">5</eet
/makePDFResponse
/soap:Body
/soap:Envelope
--------------------------
Please post a small WSDL that reproduces the problem. Also, please post the
entire exception, including any inner exceptions.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #3  
Old   
Sebastian M
 
Posts: n/a

Default Re: Trouble with complex return types - 01-03-2008 , 05:44 AM



Quote:
Please post a small WSDL that reproduces the problem. Also, please post the
entire exception, including any inner exceptions.
Sure... Here is the smallest WSDL I could produce:
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- WSDL for http://172.16.120.2/WebServices/rqh.soap created by
Pod::WSDL version: 0.05 on Thu Jan 3 10:47:31 2008 -->
<wsdl:definitions targetNamespace="http://172.16.120.2/qad"
xmlns:impl="http://172.16.120.2/qad" xmlns:wsdlsoap="http://
schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/
wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://
172.16.120.2/qad">

<wsdl:types>
<schema targetNamespace="http://172.16.120.2/qad" xmlns="http://
www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<complexType name="RetDataType">
<sequence>
<element name="refid" nillable="true" type="xsd:string">
</element>
<element name="eet" nillable="true" type="xsd:int">
</element>
</sequence>
</complexType>
</schema>
</wsdl:types>

<wsdl:message name="makePDFRequest">
</wsdl:message>

<wsdl:message name="makePDFResponse">
<wsdlart name="makePDFReturn" type="tns1:RetDataType" />
</wsdl:message>

<wsdlortType name="qadHandler">
<wsdlperation name="makePDF">
<wsdl:input message="impl:makePDFRequest" name="makePDFRequest" />
<wsdlutput message="impl:makePDFResponse" name="makePDFResponse" /
Quote:
/wsdlperation

</wsdlortType>

<wsdl:binding name="qadSoapBinding" type="impl:qadHandler">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/
soap/http" />

<wsdlperation name="makePDF">
<wsdlsoapperation soapAction="" />
<wsdl:input name="makePDFRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/" namespace="http://172.16.120.2/qad" use="encoded" />
</wsdl:input>
<wsdlutput name="makePDFResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/" namespace="http://172.16.120.2/qad" use="encoded" />
</wsdlutput>
</wsdlperation>

</wsdl:binding>

<wsdl:service name="qadHandlerService">
<wsdlort binding="impl:qadSoapBinding" name="qad">
<wsdlsoap:address location="http://172.16.120.2/WebServices/
rqh.soap" />
</wsdlort>
</wsdl:service>

</wsdl:definitions>
------------------------

Please note the error messages are in german, I put my translation in
curly braces.
------------------------
System.InvalidOperationException was unhandled
Message="Fehler im XML-Dokument (1,443)." {error in XML document}
Source="System.Xml"
StackTrace:
bei
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
bei
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
bei
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
bei
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
bei qadHandlerService.makePDF()
bei ConsoleApplication1.Program.Main(String[] args)
bei System.AppDomain._nExecuteAssembly(Assembly assembly,
String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
bei
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
bei System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException: System.InvalidCastException
Message="Ein Objekt des Typ System.String kann nicht einem
Objekt des Typs RetDataType zugewiesen werden."
{An object of type System.String can not be assigend to an object of
type RetDataType}
Source="wb_uie1t"
StackTrace:
bei
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReaderqadHandlerService.Read5_makePDFR esponse()
bei
Microsoft.Xml.Serialization.GeneratedAssembly.Arra yOfObjectSerializer2.Deserialize(XmlSerializationR eader
reader)
bei
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
InnerException:
-------------------------------

This is the program code: (note I switched from VS2008 Express to
VS2008 Professional, if that matters)
-------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Net.ServicePointManager.Expect100Continue =
false; // server not http/1.1 compliant
qadHandlerService temp = new qadHandlerService();

RetDataType ret = temp.makePDF(); // throws Exception
}
}
}
--------------------------------------

It would be great if you could give me a hint...

Best regards,
Sebastian


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.