Loading ...
Sorry, an error occurred while loading the content.

Consuming complex types in C# .NET Visual Studio

Expand Messages
  • migvan
    This may be a bit of an off topic but since it has to do with SOAP interoperability, chances are someone may have dealt with this. I have a working SOAP web
    Message 1 of 2 , Feb 4, 2006
    • 0 Attachment
      This may be a bit of an off topic but since it has to do with SOAP
      interoperability, chances are someone may have dealt with this.

      I have a working SOAP web service with an array of structs that needs
      to be consumed by a C#.
      It works fine with my PERL SOAP::Lite client.

      I created a working WSDL file and all seems well when testing it with
      a generic soap client. (Also with Stylus Studio, which has a .NET mode).

      The problem is in MS C# Express/Visual Studio. When trying to consume
      the service, I get the following:
      "Cannot implicitly convert type
      'WindowsApplication1.MyClass.MyObject[]' to 'System.Xml.XmlDocument'"

      This is the web service return line:

      return SOAP::Data->name("PersonObject" =>
      @rows)->type("typeObject")->uri('urn:ABC');

      Here is C# code:

      using System;
      using System.Data;
      using System.Text;
      using System.Windows.Forms;
      using System.Xml;

      namespace WindowsApplication1
      {
      public partial class Form1 : Form
      {
      public Form1()
      {
      InitializeComponent();
      }

      private void button1_Click(object sender, EventArgs e)
      {
      ABC.allPersonsService myPersons = new ABC.allPersonsService();
      XmlDocument MyXML;
      MyXML = myPersons.allPersons();
      }
      }
      }

      And here is the WSDL:
      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="ABC"
      targetNamespace="urn:ABC"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="urn:ABC"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <types>
      <xsd:schema targetNamespace="urn:ABC">
      <xsd:complexType name="Person">
      <xsd:all>
      <xsd:element name="id" type="xsd:string"/>
      <xsd:element name="name" type="xsd:string"/>
      </xsd:all>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfPerson">
      <xsd:complexContent>
      <xsd:restriction base="enc:Array">
      <xsd:attribute ref="enc:arrayType"
      wsdl:arrayType="tns:Person[ ]" />
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>
      </xsd:schema>
      </types>
      <message name="allPersonsRequest">
      </message>
      <message name="allPersonsResponse">
      <part name="PersonResponse" type="tns:ArrayOfPerson"/>
      </message>


      <portType name="allPersonsPort">
      <operation name="allPersons">
      <input message="tns:allPersonsRequest"/>
      <output message="tns:allPersonsResponse"/>
      </operation>
      </portType>

      <binding name="SOAP" type="tns:allPersonsPort">
      <soap:binding style="rpc"
      transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="allPersons">
      <soap:operation soapAction="urn:ABC#allPersons"/>
      <input>
      <soap:body use="encoded"
      namespace="urn:ABC"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>

      <output>
      <soap:body use="encoded"
      namespace="urn:ABC"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
      </operation>
      </binding>

      <service name="allPersonsService">
      <documentation>Testing 123</documentation>
      <port name="allPersonsPort" binding="tns:SOAP">
      <soap:address
      location="http://myhost/cgi-bin/test.pl"/>
      </port>
      </service>
      </definitions>
    • migvan
      A small correction to my previous post. The C# error is: Cannot implicitly convert type WindowsApplication1.ABC.Person[] to System.Xml.XmlDocument and
      Message 2 of 2 , Feb 4, 2006
      • 0 Attachment
        A small correction to my previous post.
        The C# error is:
        "Cannot implicitly convert type 'WindowsApplication1.ABC.Person[]' to
        'System.Xml.XmlDocument'" and not what I posted previously...

        Thnaks.
      Your message has been successfully submitted and would be delivered to recipients shortly.