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

working client example for ops.espacenet.com : WSDL, MIME attachment

Expand Messages
  • Mike
    #!/usr/bin/perl -w use SOAP::Lite; # +trace = [ debug ] ; print SOAP Lite version , $SOAP::Lite::VERSION , n ; #tested on 0.69 use MIME::Entity; my $soap
    Message 1 of 1 , Sep 13, 2007
    View Source
    • 0 Attachment
      #!/usr/bin/perl -w

      use SOAP::Lite; # +trace => ['debug'] ; print 'SOAP Lite version ',
      $SOAP::Lite::VERSION ,"\n"; #tested on 0.69
      use MIME::Entity;

      my $soap = SOAP::Lite->new();
      $soap->proxy('http://ops.espacenet.com/OpenPatentServices/webService');
      $soap->ns('urn:EPO-OpenPatentServices');
      $soap->service('http://ops.espacenet.com/OpenPatentServices/webService/getPatentData?wsdl'
      );
      my $req_xml;

      #$req_xml = '<OpenPatentServices
      ACTION="Biblio">'.'<WORLDPATENTDATA><BIBLIO SEED="EP1000000"
      SEED_FORMAT="E"
      SEED_TYPE="PN"/>'.'</WORLDPATENTDATA></OpenPatentServices>';
      #$req_xml = '<OpenPatentServices
      ACTION="FamilyAndLegalAndBiblio"><WORLDPATENTDATA><FAMILY SEED=" US
      5000063%%" SEED_FORMAT="D" SEED_TYPE="PN" DESC_LNG="ENG"
      DATE_MIGR="00000000"
      LEGAL="YES"/></WORLDPATENTDATA></OpenPatentServices>';
      $req_xml = '<OpenPatentServices
      ACTION="Claims"><WORLDPATENTDATA><BIBLIO SEED="EP1000000"
      SEED_FORMAT="E" SEED_TYPE="PN"/></WORLDPATENTDATA></OpenPatentServices>';
      my $som = $soap->getPatentData($req_xml);

      if ( $som->fault ) { # will be defined if Fault element is in the
      message
      print $som->faultstring; # returns value of 'detail' element as
      }
      else {print "no error. \n";print $som->result, "\n";
      }

      $req_xml = '<OpenPatentServices
      ACTION="DocumentInquiry"><WORLDPATENTDATA><INQUIRY SEED="EP1000000"
      SEED_FORMAT="E" SEED_TYPE="PN"/></WORLDPATENTDATA></OpenPatentServices>';
      $som = $soap->getPatentData($req_xml);
      print 'result: "', $som->result, "\"\n\n";

      $req_xml = '<OpenPatentServices
      ACTION="DocumentRetrieval"><WORLDPATENTDATA><DOCUMENT ID="EP
      1000000PAFP " SYSTEM="BNS" FORMAT="SINGLE_PAGE_TIFF"
      PAGE_NUMBER="1"/></WORLDPATENTDATA></OpenPatentServices>';

      #$req_xml = '<OpenPatentServices
      ACTION="DocumentRetrieval"><WORLDPATENTDATA><DOCUMENT ID="EP
      1000000PAFP " SYSTEM="BNS" FORMAT="SINGLE_PAGE_PDF"
      PAGE_NUMBER="1"/></WORLDPATENTDATA></OpenPatentServices>';

      # change the namespace! eliminate the error.
      $soap-> ns('urn:EPO-OpenPatentServices-documentData');
      $som = $soap->getDocumentData($req_xml);

      if ( $som->fault ) { # will be defined if Fault element is in the
      message
      print $som->faultstring; # returns value of 'detail' element
      }
      else {
      my $mime_entity = ${ $som->parts }[0];
      my $body = $mime_entity->bodyhandle;
      open( OUT, '>1.tif' ) or die "whoops $!";

      #open ( OUT , '>1.pdf' ) or die "whoops $!" ;
      binmode(OUT);
      print OUT $body->as_string;
      close OUT;
      print "no error with Document Retrieval; check file system for
      output.\n";
      }

      # watch for embedded spaces and html encoding
      # - show source, or use the base 64 attachment.
      # and http://www.motobit.com/util/base64-decoder-encoder.asp

      IyEvdXNyL2Jpbi9wZXJsIC13DQoNCnVzZSBTT0FQOjpMaXRlOyAjICt0cmFjZSA9PiBbJ2RlYnVn
      J10gOyBwcmludCAnU09BUCBMaXRlIHZlcnNpb24gJywgJFNPQVA6OkxpdGU6OlZFUlNJT04gLCJc
      biI7ICAjdGVzdGVkIG9uIDAuNjkNCnVzZSBNSU1FOjpFbnRpdHk7DQoNCm15ICRzb2FwID0gU09B
      UDo6TGl0ZS0+bmV3KCk7DQokc29hcC0+cHJveHkoJ2h0dHA6Ly9vcHMuZXNwYWNlbmV0LmNvbS9P
      cGVuUGF0ZW50U2VydmljZXMvd2ViU2VydmljZScpOw0KJHNvYXAtPm5zKCd1cm46RVBPLU9wZW5Q
      YXRlbnRTZXJ2aWNlcycpOw0KJHNvYXAtPnNlcnZpY2UoJ2h0dHA6Ly9vcHMuZXNwYWNlbmV0LmNv
      bS9PcGVuUGF0ZW50U2VydmljZXMvd2ViU2VydmljZS9nZXRQYXRlbnREYXRhP3dzZGwnDQopOw0K
      bXkgJHJlcV94bWw7DQoNCiMkcmVxX3htbCAgPSAnPE9wZW5QYXRlbnRTZXJ2aWNlcyBBQ1RJT049
      IkJpYmxpbyI+Jy4nPFdPUkxEUEFURU5UREFUQT48QklCTElPIFNFRUQ9IkVQMTAwMDAwMCIgU0VF
      RF9GT1JNQVQ9IkUiIFNFRURfVFlQRT0iUE4iLz4nLic8L1dPUkxEUEFURU5UREFUQT48L09wZW5Q
      YXRlbnRTZXJ2aWNlcz4nOw0KIyRyZXFfeG1sICA9ICc8T3BlblBhdGVudFNlcnZpY2VzIEFDVElP
      Tj0iRmFtaWx5QW5kTGVnYWxBbmRCaWJsaW8iPjxXT1JMRFBBVEVOVERBVEE+PEZBTUlMWSBTRUVE
      PSIgVVMgNTAwMDA2MyUlIiBTRUVEX0ZPUk1BVD0iRCIgU0VFRF9UWVBFPSJQTiIgREVTQ19MTkc9
      IkVORyIgREFURV9NSUdSPSIwMDAwMDAwMCIgTEVHQUw9IllFUyIvPjwvV09STERQQVRFTlREQVRB
      PjwvT3BlblBhdGVudFNlcnZpY2VzPic7DQokcmVxX3htbCA9ICc8T3BlblBhdGVudFNlcnZpY2Vz
      IEFDVElPTj0iQ2xhaW1zIj48V09STERQQVRFTlREQVRBPjxCSUJMSU8gU0VFRD0iRVAxMDAwMDAw
      IiBTRUVEX0ZPUk1BVD0iRSIgU0VFRF9UWVBFPSJQTiIvPjwvV09STERQQVRFTlREQVRBPjwvT3Bl
      blBhdGVudFNlcnZpY2VzPic7DQpteSAkc29tID0gJHNvYXAtPmdldFBhdGVudERhdGEoJHJlcV94
      bWwpOw0KDQppZiAoICRzb20tPmZhdWx0ICkgeyAgICAjIHdpbGwgYmUgZGVmaW5lZCBpZiBGYXVs
      dCBlbGVtZW50IGlzIGluIHRoZSBtZXNzYWdlDQoJcHJpbnQgJHNvbS0+ZmF1bHRzdHJpbmc7ICAg
      ICMgcmV0dXJucyB2YWx1ZSBvZiAnZGV0YWlsJyBlbGVtZW50IGFzDQp9DQplbHNlIHtwcmludCAi
      bm8gZXJyb3IuIFxuIjtwcmludCAkc29tLT5yZXN1bHQsICJcbiI7DQp9DQoNCiRyZXFfeG1sID0g
      JzxPcGVuUGF0ZW50U2VydmljZXMgQUNUSU9OPSJEb2N1bWVudElucXVpcnkiPjxXT1JMRFBBVEVO
      VERBVEE+PElOUVVJUlkgU0VFRD0iRVAxMDAwMDAwIiBTRUVEX0ZPUk1BVD0iRSIgU0VFRF9UWVBF
      PSJQTiIvPjwvV09STERQQVRFTlREQVRBPjwvT3BlblBhdGVudFNlcnZpY2VzPic7DQokc29tID0g
      JHNvYXAtPmdldFBhdGVudERhdGEoJHJlcV94bWwpOw0KcHJpbnQgJ3Jlc3VsdDogIicsICRzb20t
      PnJlc3VsdCwgIlwiXG5cbiI7DQoNCiRyZXFfeG1sID0gJzxPcGVuUGF0ZW50U2VydmljZXMgQUNU
      SU9OPSJEb2N1bWVudFJldHJpZXZhbCI+PFdPUkxEUEFURU5UREFUQT48RE9DVU1FTlQgSUQ9IkVQ
      ICAgMTAwMDAwMFBBRlAgIiBTWVNURU09IkJOUyIgRk9STUFUPSJTSU5HTEVfUEFHRV9USUZGIiBQ
      QUdFX05VTUJFUj0iMSIvPjwvV09STERQQVRFTlREQVRBPjwvT3BlblBhdGVudFNlcnZpY2VzPic7
      DQoNCiMkcmVxX3htbCAgPSAnPE9wZW5QYXRlbnRTZXJ2aWNlcyBBQ1RJT049IkRvY3VtZW50UmV0
      cmlldmFsIj48V09STERQQVRFTlREQVRBPjxET0NVTUVOVCBJRD0iRVAgICAxMDAwMDAwUEFGUCAi
      IFNZU1RFTT0iQk5TIiBGT1JNQVQ9IlNJTkdMRV9QQUdFX1BERiIgUEFHRV9OVU1CRVI9IjEiLz48
      L1dPUkxEUEFURU5UREFUQT48L09wZW5QYXRlbnRTZXJ2aWNlcz4nOw0KDQojIGNoYW5nZSB0aGUg
      bmFtZXNwYWNlISAgZWxpbWluYXRlIHRoZSBlcnJvci4gDQokc29hcC0+IG5zKCd1cm46RVBPLU9w
      ZW5QYXRlbnRTZXJ2aWNlcy1kb2N1bWVudERhdGEnKTsNCiRzb20gPSAkc29hcC0+Z2V0RG9jdW1l
      bnREYXRhKCRyZXFfeG1sKTsNCg0KaWYgKCAkc29tLT5mYXVsdCApIHsgICAgIyB3aWxsIGJlIGRl
      ZmluZWQgaWYgRmF1bHQgZWxlbWVudCBpcyBpbiB0aGUgbWVzc2FnZQ0KCXByaW50ICRzb20tPmZh
      dWx0c3RyaW5nOyAgICAjIHJldHVybnMgdmFsdWUgb2YgJ2RldGFpbCcgZWxlbWVudA0KfQ0KZWxz
      ZSB7DQoJbXkgJG1pbWVfZW50aXR5ID0gJHsgJHNvbS0+cGFydHMgfVswXTsNCglteSAkYm9keSAg
      ICAgICAgPSAkbWltZV9lbnRpdHktPmJvZHloYW5kbGU7DQoJb3BlbiggT1VULCAnPjEudGlmJyAp
      IG9yIGRpZSAid2hvb3BzICQhIjsNCg0KCSNvcGVuICggT1VUICwgJz4xLnBkZicgKSBvciBkaWUg
      Indob29wcyAkISIgOw0KCWJpbm1vZGUoT1VUKTsNCglwcmludCBPVVQgJGJvZHktPmFzX3N0cmlu
      ZzsNCgljbG9zZSBPVVQ7DQoJcHJpbnQgIm5vIGVycm9yIHdpdGggRG9jdW1lbnQgUmV0cmlldmFs
      OyBjaGVjayBmaWxlIHN5c3RlbSBmb3Igb3V0cHV0LlxuIjsNCn0NCg==
    Your message has been successfully submitted and would be delivered to recipients shortly.