【发布时间】:2016-06-02 16:44:12
【问题描述】:
当前的 Azure SDK for PHP 是否支持 Windows Server 1.1 的服务总线? 如果是,应该如何配置才能成功连接并发布到总线?
我发现连接字符串中有一个附加参数,可以更改 StsEndpoint,我用它来使用服务总线的 STS,但我收到<Error><Code>404</Code><Detail>No service is hosted at the specified address..。
我正在使用的代码:
<?php
echo "Here we go...\n";
require_once 'vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
use WindowsAzure\ServiceBus\Models\BrokeredMessage;
echo "Create Service Bus REST proxy.\n";
$connectionString = 'Endpoint=sb://myhost.mydomain/myNamespace;StsEndpoint=https://myhost.mydomain:9355/myNamespace;SharedSecretIssuer=theSASName;SharedSecretValue=theSASKey';
$serviceBusRestProxy = ServicesBuilder::getInstance()->createServiceBusService($connectionString);
try {
echo "Create message. \n";
$message = new BrokeredMessage();
$message->setBody("my message");
echo "Send message. \n";
$serviceBusRestProxy->sendQueueMessage("my-queue", $message);
} catch(ServiceException $e) {
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message .";\n";
}
echo "The End! \n";
?>
【问题讨论】:
-
据我所知,如果我们要使用 Azure 服务总线 SDK,端点格式类似于 '[yourNamespace].servicebus.windows.net'。如果您想使用 REST API,请参考此 C# 代码:stackoverflow.com/a/21754862/4836342
-
使用 Azure 服务总线时是“[yourNamespace].servicebus.windows.net”。这是我要的本地版本,它是使用的服务器主机名。
标签: php azure azureservicebus servicebus azure-sdk-php