【问题标题】:PHP SOAP call parameters for GUIDGUID 的 PHP SOAP 调用参数
【发布时间】:2014-03-06 15:11:48
【问题描述】:

我正在为我的一个客户实现 Web 服务,该方法需要 3 个参数(用户名、密码)和一个空的 GUID,应该作为参考传入。我尝试了多种选择,但无法弄清楚问题所在。有什么想法吗?

 <?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
     <LogonAndRequestToken xmlns="">
       <username>string</username>
       <password>string</password>
       <guid>guid</guid>
     </LogonAndRequestToken>
   </soap:Body>
 </soap:Envelope>

我目前正在使用以下代码:

       //$guid = "00000000-0000-0000-0000-000000000000";
       if($this->utilities->ping()->PingResult->ErrorCode == 0) {
           pr($this->utilities->LogonAndRequestToken(array("username" => "username", "password" => "pass", "guid" => 00000000-0000-0000-0000-000000000000)));
       }
       exit;

pr() 是 print_r() 的简写函数,我已经尝试了现在的 GUID 以及注释掉的版本。使用现在的版本,我得到一个异常,即 GUID 格式不正确,注释掉的一个给出了来自服务器的响应,但表明存在 10001 错误(技术错误,我应该联系支持人员)。 因为我确信用户名和密码是正确的,所以我确定我遗漏了一些东西。任何帮助将不胜感激!

这里有更多信息:

来自服务描述:

 <s:complexType>
      <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/>
           <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
           <s:element minOccurs="1" maxOccurs="1" name="guid" type="s1:guid"/>
      </s:sequence>
 </s:complexType>

我还尝试了以下选项: 数组(...,"guid" => &$guid)

【问题讨论】:

  • GUID 无效。您需要指定使用的 guid 算法的版本和变体。没有“默认”,您可以通过的空 guid。不管是不是向导。您是否尝试过传递一个空字符串?
  • 我尝试了一个空字符串并引用了一个空变量:XML 文档中存在错误 (2, 242)。 ---> System.FormatException:无法识别的 Guid 格式。在 System.Guid.GuidResult.SetFailure
  • 您是否尝试过生成 guid?像这样:php.net/manual/de/function.uniqid.php#107512 ?
  • 你能粘贴你的 wsdl 部分吗,这个 guid 元素是在哪里定义的?当您的网络服务期待 s1:guid 类型的对象时,您正在发送字符串。

标签: php asp.net web-services soap


【解决方案1】:

你也可以像这样通过 php 创建一个 guid:

public static function GenerateGuid()
{
    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        // 32 bits for "time_low"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
        // 16 bits for "time_mid"
        mt_rand( 0, 0xffff ),
        // 16 bits for "time_hi_and_version"
        mt_rand( 0, 0x0fff ) | 0x4000,
        // 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low"
        mt_rand( 0, 0x3fff ) | 0x8000,
        // 48 bits for "node"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
    );
}

http://www.php.net/manual/en/function.uniqid.php#94959

【讨论】:

    【解决方案2】:

    我通过实施 PHP COM 插件并使用 com_create_guid 函数来修复它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-20
      • 1970-01-01
      相关资源
      最近更新 更多