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

need help building a client from a wsdl

Expand Messages
  • Ian Harisay
    Hi, hopefully someone can help me make this work. I just don t see what I am doing wrong here. I have written my client in Java. The Java code is working.
    Message 1 of 1 , Aug 16, 2007
    View Source
    • 0 Attachment
      Hi,

      hopefully someone can help me make this work. I just don't see what I
      am doing wrong here. I have written my client in Java. The Java code
      is working. I would really like to get this to work under perl instead.

      Working Java code block:

      private static final String END_POINT =
      "http://206.210.94.165/keystone/services/External?wsdl";


      public static void main(String args[]) {
      String USER_IDENTIFIER = "test_user_000000002";
      String ORG_CODE = "MY_COMPANY";
      String DIGEST = "";
      String PART_NUMBER = "10071";
      String PROGRAM = "fit_for_life";
      String SEED = "9f05343d89fec4";

      try {

      // Create the digest for security when communicating from
      3rd Party
      // To the SenseWear Application.
      String stamp = AuthenticationHandler.createTimestamp();
      DIGEST = AuthenticationHandler.createDigest(stamp,
      USER_IDENTIFIER, SEED);

      External service = new External_Impl(END_POINT);
      ExternalPortType port =
      service.getExternalSOAP11Port_Http();
      ExternalCreateUser user = new ExternalCreateUser();

      user.setUser(USER_IDENTIFIER);
      user.setOrgCode(ORG_CODE);
      user.setDigest(DIGEST);
      user.setProgram(PROGRAM);
      user.setTimestamp(stamp);
      user.setSubscription(PART_NUMBER);

      ExternalCreateUserResponse c_Response =
      port.externalCreate(user);

      if (c_Response.getReturn().booleanValue()) {
      System.out.println("--External User Created-- ");
      System.out.println("Error Code: " +
      c_Response.getCode());
      } else {
      System.out.println("--External Create Failure--");
      System.out.println("Error Code: " +
      c_Response.getCode());
      }

      } catch (Exception ex) {
      System.out.println("Unable to create the ExternalStub");
      ex.printStackTrace();
      }


      Perl code that doesn't work (yet :)

      use strict;
      use Digest::MD5 qw(md5_hex);
      use Data::Dumper;
      use Time::CTime;
      use SOAP::Lite;

      my $seed = '9f05343d89fec4';
      my $org_code = 'MY_COMPANY';
      my $user = 'bill_the_user'.$$;
      my $subscription = '10071';
      my $program = 'fit_for_life';
      my $timestamp = get_timestamp();
      my $digest = get_digest();

      print "Connecting to Bodymedia web services...\n";
      my $response = SOAP::Lite
      ->service('http://206.210.94.165/keystone/services/External?wsdl')
      ->externalCreate(
      'orgCode' => $org_code,
      'user' => $user,
      'program' => 'fit_weight',
      'subscription' => '10071',
      'digest' => $digest,
      'timestamp' => $timestamp);

      print Dumper($response);

      sub get_digest {
      return md5_hex($timestamp.$user.$seed);
      }

      sub get_timestamp {
      return strftime('%Y-%m-%d %X' ,localtime(time));
      }

      Thanks for any help I can get
    Your message has been successfully submitted and would be delivered to recipients shortly.