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

SOAP::Lite server, .NET client, complex types

Expand Messages
  • grant beattie
    hi all, I know this has come up multiple times previously, and I ve tried to put together the bits of responses and code examples that work for others, but I
    Message 1 of 2 , May 24, 2004
    • 0 Attachment
      hi all,

      I know this has come up multiple times previously, and I've tried to
      put together the bits of responses and code examples that work for
      others, but I still can't get this to work as it should. simple types
      work just fine (with the default serializer), but complex types are
      giving me pain.

      I am needing to return an array of hashes (mailbox headers), and am
      using the literal serializer verbatim from:

      http://ads.harvard.edu/~alberto/SOAP/

      I believe SOAP::Lite is doing what it should be, the XML sent to the
      .NET client looks like:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:S
      OAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schem
      as.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
      <getBlockedHeadersResponse xmlns="http://blah.blah/AntiSpam">
      <resultElements>
      <resultElement>
      <msg_id>1BORWB-0003Rm-0</msg_id>
      <timestamp>1084534220</timestamp>
      <size>4331</size>
      <from>test@...</from>
      <subject>test message</subject>
      </resultElement>
      <resultElement>
      <msg_id>1BORXf-0003SR-0</msg_id>
      <timestamp>1084534279</timestamp>
      <size>1211</size>
      <from>grant@...</from>
      <subject>blah</subject>
      </resultElement>
      </resultElements>
      </getBlockedHeadersResponse>

      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      .NET doesn't complain about the XML returned, but it simply doesn't see
      "resultElements" as an array, so I suspect the problem lies with the
      wsdl, which looks like:


      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="AntiSpam"
      targetNamespace="urn:AntiSpam"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="urn:AntiSpam"
      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 xmlns="http://www.w3.org/2001/XMLSchema"
      targetNamespace="urn:AntiSpam">

      <xsd:complexType name="ResultElement">
      <xsd:all>
      <xsd:element name="msg_id" type="xsd:string"/>
      <xsd:element name="timestamp" type="xsd:int"/>
      <xsd:element name="size" type="xsd:int"/>
      <xsd:element name="from" type="xsd:string"/>
      <xsd:element name="subject" type="xsd:string"/>
      </xsd:all>
      </xsd:complexType>

      <xsd:complexType name="ResultElementArray">
      <xsd:complexContent>
      <xsd:restriction base="Array">
      <xsd:attribute ref="arrayType" wsdl:arrayType="tns:ResultElement[]"/>
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>

      <xsd:complexType name="BlockedHeadersResult">
      <xsd:all>
      <xsd:element name="resultElements" type="tns:ResultElementArray"/>
      </xsd:all>
      </xsd:complexType>

      </xsd:schema>
      </types>

      <message name="getBlockedHeadersRequest">
      <part name="address" type="xsd:string"/>
      </message>

      <message name="getBlockedHeadersResponse">
      <part name="getBlockedHeadersResult" type="tns:BlockedHeadersResult"/>
      </message>

      <portType name="AntiSpamPort">
      <operation name="getBlockedHeaders">
      <input message="tns:getBlockedHeadersRequest" />
      <output message="tns:getBlockedHeadersResponse" />
      </operation>
      </portType>

      <binding name="SOAP" type="tns:AntiSpamPort">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

      <operation name="getBlockedHeaders">
      <soap:operation soapAction="urn:AntiSpam#getBlockedHeaders" />

      <input>
      <soap:body use="encoded"
      namespace="urn:AntiSpam"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>

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

      </operation>
      </binding>

      <service name="AntiSpamService">
      <port name="AntiSpamPort" binding="tns:SOAP">
      <soap:address location="http://192.168.1.1/cgi-bin/spam.cgi" />
      </port>
      </service>

      </definitions>


      any wsdl/.NET gurus who can tell me what might be messed up here? I
      have little to no clue about wsdl or .NET. :)

      grant.
    • Maurice McCabe
      I use Alberto s serializer as well and am able to send pretty much whatever I want to and from .NET (including DataSets). It seems that .NET expects
      Message 2 of 2 , May 25, 2004
      • 0 Attachment
        Message
        I use Alberto's serializer as well and am able to send pretty much whatever I want to and from .NET (including DataSets).
         
        It seems that .NET expects "document/literal" formatted SOAP messages. So instead of declaring "rpc/encoded" in the binding section of the WSDL, I use "document/literal". For example, instead of :
         
          <binding name="SOAP" type="tns:AntiSpamPort">
            <soap:binding style="rpc" transport="
        http://schemas.xmlsoap.org/soap/http" />

            <operation name="getBlockedHeaders">
              <soap:operation soapAction="urn:AntiSpam#getBlockedHeaders" />

              <input>
                <soap:body use="encoded"
                           namespace="urn:AntiSpam"
                           encodingStyle="
        http://schemas.xmlsoap.org/soap/encoding/"/>
              </input>

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

            </operation>
          </binding>
         
        I would use:
         
          <binding name="SOAP" type="tns:AntiSpamPort">
            <soap:binding style="document" transport="
        http://schemas.xmlsoap.org/soap/http" />

            <operation name="getBlockedHeaders">
              <soap:operation soapAction="urn:AntiSpam#getBlockedHeaders" style="document" />

              <input>
                <soap:body use="literal" />
              </input>

              <output>
                <soap:body use="literal" />
              </output>

            </operation>
          </binding>
         
        BTW: you can invoke web services interactively from .NET using Web Service Studio:
         
        This is a great tool for debugging problems on the .NET side.
         
        There may be other issues with your WSDL. The Web Service Studio sometimes generates detailed error messages that can help.
         
        Maurice
         
        -----Original Message-----
        From: grant beattie [mailto:yahoo@...]
        Sent: Monday, May 24, 2004 7:30 PM
        To: soaplite@yahoogroups.com
        Subject: [soaplite] SOAP::Lite server, .NET client, complex types

        hi all,

        I know this has come up multiple times previously, and I've tried to
        put together the bits of responses and code examples that work for
        others, but I still can't get this to work as it should. simple types
        work just fine (with the default serializer), but complex types are
        giving me pain.

        I am needing to return an array of hashes (mailbox headers), and am
        using the literal serializer verbatim from:

              http://ads.harvard.edu/~alberto/SOAP/

        I believe SOAP::Lite is doing what it should be, the XML sent to the
        .NET client looks like:

        <?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:S
        OAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schem
        as.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <SOAP-ENV:Body>
        <getBlockedHeadersResponse xmlns="http://blah.blah/AntiSpam">
          <resultElements>
            <resultElement>
              <msg_id>1BORWB-0003Rm-0</msg_id>
              <timestamp>1084534220</timestamp>
              <size>4331</size>
              <from>test@...</from>
              <subject>test message</subject>
            </resultElement>
            <resultElement>
              <msg_id>1BORXf-0003SR-0</msg_id>
              <timestamp>1084534279</timestamp>
              <size>1211</size>
              <from>grant@...</from>
              <subject>blah</subject>
            </resultElement>
          </resultElements>
        </getBlockedHeadersResponse>

        </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>

        .NET doesn't complain about the XML returned, but it simply doesn't see
        "resultElements" as an array, so I suspect the problem lies with the
        wsdl, which looks like:


        <?xml version="1.0" encoding="UTF-8"?>
        <definitions name="AntiSpam"
                     targetNamespace="urn:AntiSpam"
                     xmlns="http://schemas.xmlsoap.org/wsdl/"
                     xmlns:tns="urn:AntiSpam"
                     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 xmlns="http://www.w3.org/2001/XMLSchema"
                        targetNamespace="urn:AntiSpam">

              <xsd:complexType name="ResultElement">
                <xsd:all>
                  <xsd:element name="msg_id"                type="xsd:string"/>
                  <xsd:element name="timestamp"             type="xsd:int"/>
                  <xsd:element name="size"                  type="xsd:int"/>
                  <xsd:element name="from"                  type="xsd:string"/>
                  <xsd:element name="subject"               type="xsd:string"/>
                </xsd:all>
              </xsd:complexType>

              <xsd:complexType name="ResultElementArray">
                <xsd:complexContent>
                  <xsd:restriction base="Array">
                     <xsd:attribute ref="arrayType" wsdl:arrayType="tns:ResultElement[]"/>
                  </xsd:restriction>
                </xsd:complexContent>
              </xsd:complexType>
           
              <xsd:complexType name="BlockedHeadersResult">
                <xsd:all>
                  <xsd:element name="resultElements" type="tns:ResultElementArray"/>
                </xsd:all>
              </xsd:complexType>

            </xsd:schema>
          </types>
         
          <message name="getBlockedHeadersRequest">
            <part  name="address" type="xsd:string"/>
          </message>

          <message name="getBlockedHeadersResponse">
            <part  name="getBlockedHeadersResult" type="tns:BlockedHeadersResult"/>
          </message>

          <portType name="AntiSpamPort">
            <operation name="getBlockedHeaders">
              <input  message="tns:getBlockedHeadersRequest" />
              <output message="tns:getBlockedHeadersResponse" />
            </operation>
          </portType>
         
          <binding name="SOAP" type="tns:AntiSpamPort">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

            <operation name="getBlockedHeaders">
              <soap:operation soapAction="urn:AntiSpam#getBlockedHeaders" />

              <input>
                <soap:body use="encoded"
                           namespace="urn:AntiSpam"
                           encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
              </input>

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

            </operation>
          </binding>

          <service name="AntiSpamService">
            <port name="AntiSpamPort" binding="tns:SOAP">
              <soap:address location="http://192.168.1.1/cgi-bin/spam.cgi" />
            </port>
          </service>

        </definitions>


        any wsdl/.NET gurus who can tell me what might be messed up here? I
        have little to no clue about wsdl or .NET. :)

        grant.



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