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

Help in Calling DotNet data struct from SOAP:Lite client

Expand Messages
  • chengal11
    Hi, I am fairly new to web services. I need to create a SOAP::Lite client to access a DotNet Webmethod that takes data structure as parameter. DotNet webmehtod
    Message 1 of 1 , Jul 1 3:42 PM
    • 0 Attachment
      Hi,

      I am fairly new to web services.
      I need to create a SOAP::Lite client to access a DotNet Webmethod
      that takes data structure as parameter.
      DotNet webmehtod is expecting a SOAP envelop similar to the following
      one.

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-
      instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
      <namesp1:GetArrayOfDirectories
      xmlns:namesp1="http://awctmp01.allianzlife.com">
      <namesp1:myTemplate>
      <namesp1:TemplateClass>
      <namesp1:Category
      xsi:type="xsd:string">Product_Information</namesp1:Category>
      <namesp1:DataType
      xsi:type="xsd:string">Annuities</namesp1:DataType>
      </namesp1:TemplateClass>
      <namesp1:TemplateClass>
      <namesp1:Category
      xsi:type="xsd:string">Documents</namesp1:Category>
      <namesp1:DataType
      xsi:type="xsd:string">Forms_And_Marketing_Materials</namesp1:DataType>
      </namesp1:TemplateClass>
      </namesp1:myTemplate>
      </namesp1:GetArrayOfDirectories>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Here is the DotNet code

      // WEB SERVICE
      // The GetArrayOfDirectories(TemplateClass[] myTemplate)
      // service returns the string organization specific root directories
      // To test this web service, press F5
      [ WebMethod]
      public string GetArrayOfDirectories(TemplateClass[] myTemplate)
      {
      /// more logic goes here
      return xmlString;
      }

      public class TemplateClass
      {
      public string DataType;
      public string Category;
      }


      I tried many different ways for creating soap envelop using
      SOAP::Data. I couldn't get it work.
      The following SOAP::Lite code worked. But I am not sure how to
      dynamically accept parameters

      sub getOrgTemplateConfigWrapper
      {
      my ($className, $methodName, %params) = @_;
      my $soap = SOAP::Lite
      -> uri('http://awctmp01.mysite.com')
      -> proxy('http://199.20.4.85/OrgTemplateParser/' .
      $className . '.asmx')
      -> on_action(sub{sprintf '%s/%s', @_});
      # Dynamically accept hash
      my %dataTypeCategoryHash = ();
      $dataTypeCategoryHash{"Product_Information"} = "Annuities";
      $dataTypeCategoryHash{"Documents"}
      = "Forms_And_Marketing_Materials";
      $dataTypeCategoryHash{"Links"} = "Related Links";

      my @templateClass;
      # dynamically generate parameters??
      push(@templateClass, (SOAP::Data->name("namesp1:myTemplate" =>
      \SOAP::Data->name("namesp1:TemplateClass"
      => \SOAP::Data->value(SOAP::Data->name
      ("namesp1:Category" => "Product_Information"), SOAP::Data->name
      ("namesp1:DataType" => "Annuities")),
      => \SOAP::Data->value(SOAP::Data->name
      ("namesp1:Category" => "Documents"), SOAP::Data->name
      ("namesp1:DataType" => "Forms_And_Marketing_Materials"))
      ))));
      my $result = $soap->getOrgTemplateConfig(@methodArgs);
      if ($result->fault)
      {
      return $result->faultstring;
      }
      return $result->valueof('//getOrgTemplateConfigResult');
      }

      Any help is appreciated. I need help in generating the above soap
      envelop using SOAP::Lite.

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