本文介绍了在" membername"成员不是类型的base64错误从XML-RPC服务电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是查尔斯·库克xml-rpc.net在企图使一个XML-RPC服务调用。

I'm using Charles Cook's xml-rpc.net in an attempt to make an xml-rpc service call.

请求需要以这种格式发送:

The request needs to be sent in this format:

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>leads</methodName>
<params>
<param>
<value>
<struct>
<member>
 <name>key</name>
 <value>
  <string>XXXXXXXXXXX</string>
 </value>
</member>
<member>
 <name>leads</name>
 <value>
  <base64>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGxlYWRzPgogICA8bGVhZD4K
          ICAgICAgPGlkPjM5OTk3PC9pZD4KICAgICAgPEZpcnN0TmFtZT5Cb2IgSmltPC9GaXJzdE5hbWU+
          CiAgICAgIDxMYXN0TmFtZT5TbWl0aDwvTGFzdE5hbWU+CiAgICAgIDxBZGRyZXNzPjEyMzQgV2Vz
          :
          :
          ICAgICA8UmVjZWl2ZUFkZGxJbmZvPlllczwvUmVjZWl2ZUFkZGxJbmZvPgogICAgICA8bG9wX3dj
          X3N0YXR1cz5ObzwvbG9wX3djX3N0YXR1cz4KICAgPC9sZWFkPgo8L2xlYWRzPg==
  </base64>
 </value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>



如果成员名称中包含此格式的多个标签:

Where member name contains multiple tags in 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>39997</id>
  <first_name>Jim</first_name>
  <last_name>Smith</last_name>
  <address>1234 West 5th Street</address>
  <address2/>
  <city>Beverly Hills</city>
  <state_or_province>CA</state_or_province>
  <country>USA</country>
  <postal_code>90210</postal_code>
  <best_number>555-121-3322</best_number>
  <best_number_ext/>
  <alt_number/>
  <alt_number_ext/>
  <time_zone>Pacific</time_zone>
  <best_time>mid day</best_time>
  <request_uri>http://siteName.com/contact/
               ?source=VendorName&amp;leadid=VendorId&amp;ad=SomeAd</request_uri>
  <handoff_id>X-vendorid</handoff_id>
  </lead>
  <lead>
  <id>39987</id>
  <first_name>George</first_name>
   :
   :
  <lop_wc_status>No</lop_wc_status>
  <request_uri>http://siteName.com/contact/
               ?source=VendorName&amp;leadid=VendorId&amp;ad=SomeAd</request_uri>
 </lead>
</leads>



在Web服务方法的文档要求包含两个值一个参数(值数组) - 关键并导致。包含导线数据的XML文档必须打包为二进制对象。此值必须命名为线索,并且必须是类型的base64的

The documentation on the webservice method calls for one parameter that contains two values (array of values) - key and leads. The xml document containing the leads data must be packaged as a binary object. This value must be named leads and must be of type base64.

下面是我得到了什么,到目前为止是失败的:

Here's what I got so far that is failing:

我的包含引线的信息结构 -

My struct containing the leads info-

     [Serializable]
     public struct myLeads
     {
      public string id;
      public string first_name;
      public string last_name;
     }



接口

The interface

    public interface ILead
    {
    [CookComputing.XmlRpc.XmlRpcMethod("leads", StructParams = true)]
    string NewLead(string key, myLeads leads);
    }



最后,我初始化结构值并调用方法:

Finally, I initialize the struct values and call the method:

    myLeads newLead = default(newLeads);
    Guid guid = System.Guid.NewGuid();
    newLead.id = guid.ToString();
    newLead.first_name = "Test";
    newLead.last_name = "LastNameTest";
    newLead.address = "111 Test St";

    var leadPost = (ILead)XmlRpcProxyGen.Create(typeof(ILead));
    var clientProtocol = (XmlRpcClientProtocol)leadPost;
    clientProtocol.Url =  "https://dashboard.sitename.com/webservices/rpc/xmlrpc";
    try
    {
        result = leadPost.NewLead("XXXKeyXXX", newLead);
        Label1.Text = result;
    }
    catch (Exception ex)
    {
        throw ex;
    }



我的代码抛出try块的错误:引线成员是不类型的base64!我如何设置这正常吗?

My code throws the error in the try block: The leads member is not of type base64! How do I set this up properly?

在此先感谢!

推荐答案

要引线方法的参数应该是一个结构或类包含两个成员,例如:

The parameter to the leads method should be a struct or class containing two members, for example:

public struct leadsParam
{
   public string key;
   public byte[] leads;
}

和接口是

public interface ILead
{
    [XmlRpcMethod("leads")]
    string NewLead(leadsParam leads);
}

这篇关于在&QUOT; membername&QUOT;成员不是类型的base64错误从XML-RPC服务电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 10:20