469,926 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Problem using Perl web service with C# client.

I have a perl web service (using SOAP::Lite) with a method called
"Detail" that returns a strucure (hash reference to be exact). It
works fine when consumed by a Perl client, but when I try to consume
it with a C# application, I get the following runtime error from C#:

Cannot assign object of type System.Xml.XmlNode[] to an object of
type ConsoleApplication1.com.hilton.crmdev.SummaryType.

Below is the Perl code that generates the hash, the.wsdl file, the
returned SOAP message and the C# client code. Sorry for the long post.
Any help would be greatly appreciated.

################################################## #####
### The Perl
package Test;

use strict;
use SOAP::Lite;

$SOAP::Constants::DO_NOT_USE_CHARSET = 1;

sub Detail
{
my $class = shift();
my $id = shift();
my $return = {
ID => $id,
LastName => 'Conrey',
FirstName => 'Peter',
MiddleInit => 'F',
Title => 'Mr.'
};
return SOAP::Data->name( 'SummaryType' )
->uri( "urn:Test" )
->value( $return );
}

############################################
### The WSDL file
<?xml version="1.0"?>

<definitions name="Test"
targetNamespace="urn:Test"
xmlns:tns="urn:Test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>

<xsd:schema targetNamespace="urn:Test">

<xsd:complexType name="SummaryType">
<xsd:all>
<xsd:element name="ID" type="xsd:int"
minOccurs="1" />
<xsd:element name="LastName" type="xsd:string"
minOccurs="1" />
<xsd:element name="FirstName" type="xsd:string"
minOccurs="1" />
<xsd:element name="MiddleInit" type="xsd:string"
minOccurs="1" />
<xsd:element name="Title" type="xsd:string"
minOccurs="1" />
</xsd:all>
</xsd:complexType>

</xsd:schema>

</types>

<message name="DetailRequest">
<part name="id" type="xsd:int"/>
</message>

<message name="DetailResponse">
<part name="return" type="tns:SummaryType" />
</message>

<portType name="TestDetailPort">
<operation name="Detail">
<input message="tns:DetailRequest"/>
<output message="tns:DetailResponse"/>
</operation>
</portType>

<binding name="TestDetailBinding" type="tns:TestDetailPort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Detail">
<soap:operation soapAction="urn:Test#Detail"/>
<input>
<soap:body use="encoded" namespace="urn:Test"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:Test"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>

<service name="TestDetailService">
<port name="TestDetailPort" binding="tns:TestDetailBinding">
<soap:address location="http://crmdev.hilton.com:7994/webservices/test/Test.pl"/>
</port>
</service>

</definitions>
################################################
### The SOAP Response message
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:namesp3="http://xml.apache.org/xml-soap"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<namesp1:DetailResponse xmlns:namesp1="urn:Test">
<namesp2:SummaryType xmlns:namesp2="urn:Test"
xsi:type="namesp3:SOAPStruct">
<FirstName xsi:type="xsd:string">Peter</FirstName>
<Title xsi:type="xsd:string">Mr.</Title>
<ID xsi:type="xsd:int">60441557</ID>
<MiddleInit xsi:type="xsd:string">F</MiddleInit>
<LastName xsi:type="xsd:string">Conrey</LastName>
</namesp2:SummaryType>
</namesp1:DetailResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
################################################
### The C# client
using System;
using System.Xml;
using System.Collections;

namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
com.hilton.crmdev.TestDetailService ds = new
com.hilton.crmdev.TestDetailService();
com.hilton.crmdev.SummaryType sumType = ds.Detail(60441557);
Console.WriteLine( "got it" );
Console.WriteLine( "{0} {1} {2} {3}",
sumType.Title,
sumType.FirstName,
sumType.MiddleInit,
sumType.LastName );
Console.ReadLine();
}
}
}
################################################## #####
### The auto-generated C# proxy class
namespace ConsoleApplication1.com.hilton.crmdev {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="TestDetailBinding",
Namespace="urn:Test")]
public class TestDetailService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

/// <remarks/>
public TestDetailService() {
this.Url =
"http://crmdev.hilton.com:7994/webservices/test/Test.pl";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("urn:Test#Detail",
RequestNamespace="urn:Test", ResponseNamespace="urn:Test")]
[return: System.Xml.Serialization.SoapElementAttribute("ret urn")]
public SummaryType Detail(int guest_id) {
object[] results = this.Invoke("Detail", new object[]
{guest_id});
return ((SummaryType)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginDetail(int guest_id,
System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("Detail", new object[] {guest_id},
callback, asyncState);
}

/// <remarks/>
public SummaryType EndDetail(System.IAsyncResult asyncResult)
{
object[] results = this.EndInvoke(asyncResult);
return ((SummaryType)(results[0]));
}
}

/// <remarks/>
[System.Xml.Serialization.SoapTypeAttribute("Summar yType",
"urn:Test")]
public class SummaryType {

/// <remarks/>
public int GuestID;

/// <remarks/>
public string LastName;

/// <remarks/>
public string FirstName;

/// <remarks/>
public string MiddleInit;

/// <remarks/>
public string Title;
}
}
Nov 21 '05 #1
0 2123

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Sudesh Sawant | last post: by
4 posts views Thread by Patricia Mindanao | last post: by
2 posts views Thread by =?Utf-8?B?aGVsZmk=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.