PHP 和 SOAP 中的 GUID

发布于 2024-12-14 14:50:15 字数 1018 浏览 0 评论 0原文

我正在使用 PHP 开发 Web 服务客户端。每个请求必须提供一个许可证密钥,该密钥是一个 guid,例如 17a18c4d-63ab-4eab-778f-20a67e1fe83a。

问题是,根据规范,许可证不是字符串而是 Guid,并且示例是 C 语言,例如。

ListAllBookSubjects(Guid licenseKey, LanguageCodeTypeEnum language)

如果我在 PHP 中尝试此代码片段(登录名和许可证不是实际的):

$url= "http://service.qa.pubhub.dk/MediaService1_4.asmx?WSDL";
$config = array( "login" => "[email protected]", "password" => "1234", "trace" => 1,"exceptions" => 0);
$objSoapClient = new SoapClient($url,$config);
print_r($objSoapClient->ListAllBookSubjects('{17a18c4d-63ab-4eab-778f-20a67e1fe83a}', 'DAN'));

我收到以下错误响应:

[message:protected] => System.Web.Services.Protocols.SoapException: Invalid LicenseKey {00000000-0000-0000-0000-000000000000}

我也尝试过不带大括号。显然 guid 格式是错误的,但是如何在 PHP 中表示 C Guid 呢?

我找到了答案,见下文

I am working on web service client in PHP. Each request must supply a licence key which is a guid such as 17a18c4d-63ab-4eab-778f-20a67e1fe83a.

The problem is that according to the specification, the license is not a string but a Guid and the examples are in C, eg.

ListAllBookSubjects(Guid licenseKey, LanguageCodeTypeEnum language)

If I try this snippet in PHP (login and license are not the actual ones):

$url= "http://service.qa.pubhub.dk/MediaService1_4.asmx?WSDL";
$config = array( "login" => "[email protected]", "password" => "1234", "trace" => 1,"exceptions" => 0);
$objSoapClient = new SoapClient($url,$config);
print_r($objSoapClient->ListAllBookSubjects('{17a18c4d-63ab-4eab-778f-20a67e1fe83a}', 'DAN'));

I get the following error response:

[message:protected] => System.Web.Services.Protocols.SoapException: Invalid LicenseKey {00000000-0000-0000-0000-000000000000}

I have also tried without the braces. Apparently the guid format is wrong, but how do I represent a C Guid in PHP?

I found the answer, see below

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心房的律动 2024-12-21 14:50:15

根据 WSDL http://service.qa.pubhub.dk/MediaService.asmx? WSDL ,看起来好像 GUID 是用以下模式值“定义”的:

[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4 }-[0-9a-fA-F]{12}

所以如果你不带大括号的话肯定会很好。是否有可能许可证密钥未授权或服务器上有其他内容?询问服务提供商可能会有所帮助,向他们提供一两个正在发出的 SOAP 请求的副本。

According to the WSDL at http://service.qa.pubhub.dk/MediaService.asmx?WSDL , it would seem as though a GUID is 'defined' with a pattern value of:

[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}

so it should definitely be good if you do it without the braces. Is it possible that the license key isn't authorised or something on the server? It may pay to ask the service provider, giving them a copy or two of the SOAP requests that are being made.

浅笑轻吟梦一曲 2024-12-21 14:50:15

我尝试使用 Storm 发送请求,并意识到该请求需要参数名称:

print_r($objSoapClient->ListAllBookSubjects(array("licenseKey" => "17a18c4d-63ab-4eab-778f-20a67e1fe83a", "language"=>"DAN")));

上面的版本工作完美!

我不知道 Storm,但服务提供商的支持指出了它。这似乎是一个非常有用的工具:http://storm.codeplex.com

I tried sending the request using Storm and realized that the request needed the parameter names:

print_r($objSoapClient->ListAllBookSubjects(array("licenseKey" => "17a18c4d-63ab-4eab-778f-20a67e1fe83a", "language"=>"DAN")));

The above version works perfectly!

I didn't know Storm but was pointed to it by the service provider's support. It seems be a very useful tool: http://storm.codeplex.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文