Azure Service Bus中的绝对HTTP(S)请求URL

I'm trying to setup a basic connection towards Azure's Service Bus using PHP and can't get it to work. I get the error:

1: HTTP_Request2 needs an absolute HTTP(S) request URL, 'sb://mynamespace.servicebus.windows.net/myqueue/messages' given

This is the code I'm now trying to run:

<?php
    require_once '../vendor/autoload.php';

    use WindowsAzure\Common\ServicesBuilder;
    use WindowsAzure\Common\ServiceException;
    use WindowsAzure\ServiceBus\Models\BrokeredMessage;

    // Create Service Bus REST proxy.
    $connectionString = "Endpoint=sb://mynamespace.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=[MyVal]";
    $serviceBusRestProxy = ServicesBuilder::getInstance()->createServiceBusService($connectionString);

    try {
        // Create message.
        $message = new BrokeredMessage();
        $message->setBody("my message");

        // Send message.
        $serviceBusRestProxy->sendQueueMessage("myqueue", $message); // this is the line that causes the error
    }
    catch(Exception $e){
        // Handle exception based on error codes and messages.
        // Error codes and messages are here: 
        // http://msdn.microsoft.com/library/windowsazure/hh780775
        $code = $e->getCode();
        $error_message = $e->getMessage();
        echo $code.": ".$error_message."<br />";
    }
?>

I don't understand where this is going wrong. Anyone have any idea what I can do to prevent this error?

Based on the comments here, it seems you're getting this error because you're using an older way of connecting to Azure Service Bus. Please use Shared Access Signature based connection string that you can get from Azure Portal. It should be in the following format:

$connectionString = "Endpoint=<namespacename>.servicebus.windows.net;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<your_key_from_the_portal>";

From the comments:

Hi Martin, thank you for the feedback. You are correct, the connection string in this example uses the old ACS format, while the portal produces strings that use the newer Shared Access Signature token (see https://msdn.microsoft.com/lib... for more info). I will get this topic updated ASAP.

You should be able to just substitute the new connection string from the portal. Make sure it is in the correct format. It should be something like

$connectionString = "Endpoint=.servicebus.windows.net;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=";

It's not the wrong in PHP SDK. Currently, the Azure SDK for PHP implement service bus with ACS namespace. But by default, the portal and Powershell create service bus in SAS namespace.

To use Azure SDK for PHP to handle service bus, you need to create the service bus server in ACS namespace. You can refer to https://blogs.msdn.microsoft.com/servicebus/2014/09/03/change-to-azure-service-bus-portal-default-authentication-mechanism-for-service-bus-namespaces-now-sas/ for more info.

Additionally, from the last paragraph, we can see:

ACS is still fully supported in Service Bus and will be for the foreseeable future

After creating the service bus in ACS namespace, you can find it in classic portal.

Meanwhile, Microsoft hasn't said that using connectionstring form classic portal is deprecated.