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

Re: The leads member is not of type base64!

Expand Messages
  • Donnie
    Hi Duane, Yes, I saw your post and tried that. The problem is that the method itself can only take one parameter which is an array [ key ][xxxVendorKey]
    Message 1 of 4 , Jun 1, 2012
    View Source
    • 0 Attachment
      Hi Duane,

      Yes, I saw your post and tried that. The problem is that the method itself can only take one parameter which is an array

      ['key'][xxxVendorKey] ['leads'][xmlDoc] <- xmlDoc should be a base64 binary object.

      Here's the php sample which makes things look so easy - just can't figure out how to do it in .net

      Example Below:

      <?php
      // The URL of the XML-RPC web service to submit contacts
      $service_url = 'https://dashboard.siteName.com/webservices/rpc/xmlrpc';

      // The method to be called on the remote system
      $method = 'leads';

      // Unique user key
      $key = 'VendorKey';

      // Read an XML document from disk
      $xmlDoc = file_get_contents('leads.xml');

      // Since the XML document must be fully qualified (containing an xml declaration)
      // the document must be sent in binary format. In PHP this is accomplished by
      // using the function xmlrpc_set_type
      xmlrpc_set_type($xmlDoc, 'base64');

      // Package the document and key to be sent and the method name into an xml-rpc
      // request document
      $request = xmlrpc_encode_request($method, array('key' => $key, 'leads' => $xmlDoc));

      // Initialize curl with the web services URL
      $req = curl_init($service_url);

      // Set up cURL headers for this type of request
      $headers = array();
      array_push($headers,"Content-Type: text/xml");
      array_push($headers,"Content-Length: ".strlen($request));
      array_push($headers,"\r\n");

      // URL to post to
      curl_setopt($req, CURLOPT_URL, $service_url);

      // Set options for a secure SSL based xmlrpc server
      curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($req, CURLOPT_SSL_VERIFYHOST, 2);
      curl_setopt($req, CURLOPT_CUSTOMREQUEST, 'POST' );
      curl_setopt($req, CURLOPT_RETURNTRANSFER, 1 );
      curl_setopt($req, CURLOPT_HTTPHEADER, $headers );
      curl_setopt($req, CURLOPT_POSTFIELDS, $request );

      // Make the call
      $response = curl_exec($req);

      // Close the cURL connection
      curl_close($req);

      // Decode the response to be displayed
      $r = xmlrpc_decode($response);

      if(xmlrpc_is_fault($r))
      {
      echo 'A fault occured! Fault code: ' . $r['faultCode'] . ', Fault string: ' . $r['faultString'];
      }
      else
      {
      echo 'You sent ' . $r['leadsSent'] . ' leads.';
      }
      ?>


      --- In XMLRPCNET@yahoogroups.com, "Duane Lakoduk" <duanelakoduk@...> wrote:
      >
      > If I may suggest, I think you need to rewrite your struct to use the byte[]
      > type for the base64 data and implement the IXmlRpcProxy interface, similar
      > to the below example: this.file is the base64 data in this example.
      >
      >
      >
      > public struct VideoStruct
      >
      > {
      >
      > public byte[] file;
      >
      > public string title;
      >
      > public string description;
      >
      >
      >
      > public VideoStruct(byte[] file, string title, string description)
      >
      > {
      >
      > this.file = file;
      >
      > this.title = title;
      >
      > this.description = description;
      >
      > }
      >
      > }
      >
      >
      >
      > [XmlRpcUrl("http://my.videohost.com/xmlrpc.php")]
      >
      > public interface IAddVideo : IXmlRpcProxy
      >
      > {
      >
      > [XmlRpcMethod("vbapi.addvideo")]
      >
      > int addVideo(string token, VideoStruct video);
      >
      > }
      >
      >
      >
      > ~/Duane
      >
      > _____
      >
      > From: XMLRPCNET@yahoogroups.com [mailto:XMLRPCNET@yahoogroups.com] On Behalf
      > Of Donnie
      > Sent: Friday, June 01, 2012 4:12 PM
      > To: XMLRPCNET@yahoogroups.com
      > Subject: [XMLRPCNET] Re: The leads member is not of type base64!
      >
      >
      >
      >
      >
      > Still trying to figure this out. I have a more detailed/formatted version of
      > the question here:
      >
      > http://stackoverflow.com/questions/10855156/the-membername-member-is-not-of-
      > type-base64-error-from-xml-rpc-service-call
      >
      > --- In XMLRPCNET@yahoogroups.com <mailto:XMLRPCNET%40yahoogroups.com> ,
      > "Donnie" <dhunniecutt@> wrote:
      > >
      > > Hi,
      > >
      > > I'm trying to figure out how to call this method to post data (truncated):
      > >
      > > <?xml version="1.0" encoding="iso-8859-1"?>
      > > <methodCall>
      > > <methodName>leads</methodName>
      > > <params>
      > > <param>
      > > <value>
      > > <struct>
      > > <member>
      > > <name>key</name>
      > > <value>
      > > <string>dg123lkjdslfjxx</string>
      > > </value>
      > > </member>
      > > <member>
      > > <name>leads</name>
      > > <value>
      > >
      > <base64>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGxlYWRzPgogICA8
      > bGVhZD4K
      > >
      > ICAgICAgPGlkPjM5OTk3PC9pZD4KICAgICAgPEZpcnN0TmFtZT5Cb2IgSmltPC9GaXJzdE5hbWU+
      > >
      > CiAgICAgIDxMYXN0TmFtZT5TbWl0aDwvTGFzdE5hbWU+CiAgICAgIDxBZGRyZXNzPjEyMzQgV2Vz
      > > :
      > > :
      > >
      > ICAgICA8UmVjZWl2ZUFkZGxJbmZvPlllczwvUmVjZWl2ZUFkZGxJbmZvPgogICAgICA8bG9wX3dj
      > > X3N0YXR1cz5ObzwvbG9wX3djX3N0YXR1cz4KICAgPC9sZWFkPgo8L2xlYWRzPg==
      > > </base64>
      > > </value>
      > > </member>
      > > </struct>
      > > </value>
      > > </param>
      > > </params>
      > > </methodCall>
      > >
      > >
      > > Where each <lead> has this format:
      > >
      > >
      > > <?xml version="1.0" encoding="UTF-8"?>
      > > <leads xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      > > xmlns="http://www.sitename.com/Leads"
      > > xsi:schemaLocation="http://www.sitename.com/Leads Leads.xsd"
      > > version="1.0">
      > > <lead>
      > > <id>39987</id>
      > > <first_name>Bob</first_name>
      > > :ect
      > > :ect
      > > <lop_wc_status>No</lop_wc_status>
      > > <request_uri>http://sitename.com/contact/
      > > ?source=VendorName&leadid=VendorId&ad=SomeAd</request_uri>
      > > </lead>
      > > <lead>
      > > <id>39987</id>
      > > <first_name>George</first_name>
      > > :ect
      > > :ect
      > > <lop_wc_status>No</lop_wc_status>
      > > <request_uri>http://sitename.com/contact/
      > > ?source=VendorName&leadid=VendorId&ad=SomeAd</request_uri>
      > > </lead>
      > > </leads>
      > >
      > >
      > > Here's one of many attempts I've tried.
      > > public interface ILead
      > > {
      > > [CookComputing.XmlRpc.XmlRpcMethod("leads", StructParams = true)]
      > > string NewLead(string key, newLeads leads);
      > > }
      > >
      > > [Serializable]
      > > public struct newLeads
      > > {
      > > #region Members
      > >
      > > public string id;
      > >
      > > public string first_name;
      > >
      > > public string last_name;
      > > //truncated
      > > }
      > > //Onclick event
      > > newLeads newLead = default(newLeads);
      > > Guid guid = System.Guid.NewGuid();
      > > newLead.id = guid.ToString();
      > > newLead.first_name = "Test";
      > > newLead.last_name = "LastNameTest";
      > >
      > >
      > > var leadPost = (ILead)XmlRpcProxyGen.Create(typeof(ILead));
      > > var clientProtocol = (XmlRpcClientProtocol)leadPost;
      > > clientProtocol.Url =
      > "https://dashboard.sitename.com/webservices/rpc/xmlrpc";
      > >
      > > string result = string.Empty;
      > > try
      > > {
      > > result = lsiLeadPost.NewLead("XXXXXVendorKeyXXXXX",newLead));
      > > Label1.Text = result;
      > > }
      > > catch (Exception ex)
      > > {
      > > throw ex;
      > > }
      > >
      > >
      > > Will you please show me how to set this up properly?
      > >
      > > Thanks in advance!
      > >
      >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.