Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserGetResponse17sp4- Not returning accessDeviceEndpoint or trunkAddressing #14

Open
TwinMist opened this issue Jun 8, 2017 · 1 comment
Assignees

Comments

@TwinMist
Copy link

TwinMist commented Jun 8, 2017

Hi
Within the responce of UserGetResponse is does not include the following
Start Choice [1]
AccessDeviceMultipleContactEndpointRead [0..1]
TrunkAddressingMultipleContactRead [0..1]
End Choice

cheers

@lukebeer
Copy link
Owner

Indeed, I wondered how long it would take someone else to spot it ;)

I didn't take into account <xs:choice> </xs:choice> elements being returned. There are a few places in the code that need changing to handle these correctly. I have worked around this problem before a few times very easilly but can't remember exactly how and don't currently have a system to test with. If you can provide a working login I'll review fixing it.

          <xs:choice>
            <xs:element name="accessDeviceEndpoint" type="AccessDeviceMultipleContactEndpointRead" minOccurs="0"/>
            <xs:element name="trunkAddressing" type="TrunkAddressingMultipleContactRead" minOccurs="0"/>
          </xs:choice>

To get around the problem, start by requesting a different response output format and post process from there
untested code, doubt it'll work as-is but may give you a better idea on how to get the data out you need.

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

use BroadworksOCIP\api\Rel_17_sp4_1_197_OCISchemaAS\OCISchemaUser\UserGetRequest17sp4;
use BroadworksOCIP\Builder\Builder;
use BroadworksOCIP\Response\ResponseOutput;

$client = BroadworksOCIP\Factory::getTCPClient('ocip.example.com');
if ($client->login('user', 'pass')) {
    $client->send(new UserGetRequest17sp4('userid@something.com'));

    //  Try request the response as a different outputType
    $responseAsJSON = $client->getResponse(ResponseOutput::JSON);

    //  If you need to make a new request based on the response data, Builder::buildComplex can merge into a new type
    $response = $client->getResponse();
    $responseAsSimpleXML = $client->getResponse(ResponseOutput::SIMPLEXML);
    $accessDevice = Builder::buildComplex($responseAsSimpleXML->AccessDeviceMultipleContactEndpointRead->accessDevice);

    //  If the above fails, you can access the raw response body and extract the elements manually
    $responseAsIs = $client->getLastResponseMsg();

    $client->logout();
}
?>

@lukebeer lukebeer self-assigned this May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants