PHP 和 SOAP 中的 GUID
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 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.
我尝试使用 Storm 发送请求,并意识到该请求需要参数名称:
上面的版本工作完美!
我不知道 Storm,但服务提供商的支持指出了它。这似乎是一个非常有用的工具:http://storm.codeplex.com
I tried sending the request using Storm and realized that the request needed the parameter names:
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