'Soap Call for sitemider PHP

Ok guys and girls I really tried... that is not lack of effort in here...

I got a system that books hotel, events and manage it and now I have to connect siteminder and other services. Which is great but I cannot understand how it works at all... all I get is a single error that I cannot get my head how to make it work.

So lets go cooding:

$auth = new \stdClass();
$auth->UsernameToken = new \stdClass();
$auth->UsernameToken->Username = $user;
$auth->UsernameToken->Password = $pw;

$client = new SoapClient($wsdl,array('trace'=>true));
$header = new SOAPHeader($ns, 'Security', $auth, false); 

$hresp = $client->__setSoapHeaders($header);
//This is true... so my authentication is working perfect
//var_dump($hresp);
$arr = array(
    'POS' => array(
        'Source'=> array(
            'RequestorID' => array(
                'type'=>'22',
                'ID'=>$id,
            )
        )
    ),
    'AvailStatusMessages' => array(
        'HotelCode'=>$hc,
        'AvailStatusMessage' => array(
            'StatusApplicationControl' => array(
                'Start'=>'2016-10-01',
                'End'=>'2016-10-01',
                'InvTypeCode'=>'TR',
                'RatePlanCode'=>'BAR'
            ),
            'RestrictionStatus' => array(
                'Status'=>'Close'
            )
        )
    )

);


try{
    //here is my issue
    $data = $client->__call('HotelAvailNotifRQ',array($arr));
    if($data->Errors) {
        foreach($data->Errors as $error) {
            echo "Error: ".$error;
        }
    }else {
        var_dump($data);
    }
} catch (SoapFault  $e) {
    var_dump($e);
    echo $e->faultstring;
}

Trying this I get this Error: Could not locate RequestorID/@ID in soap body

But as you can see I'm sending the requestorID

I tried in different ways, Object, XML values, SoapVar, SoapParam and many other different ways... all I get is that same error... that mean I'm for some reason not sending the requestorID when I'm actually sending it!

Couples of trials done:

$arr = array(
    'POS' => array(
        '_' => array(
            'Source' => array(
                '_' => array(
                    'RequestorID' => array(
                        'type'=>'22',
                        'ID'=>$id,
                    )
                )
            )

        )
    ),
);

$pos = new StdClass();
$pos->source->requestorID = $id;
$pos->source->type = 22;

$asm = new StdClass();
$asm->HotelCode = $hc;
$asm->AvailStatusMessage->StatusApplicationControl->Start = '2016-10-01';
$asm->AvailStatusMessage->StatusApplicationControl->End = '2016-10-02';
$asm->AvailStatusMessage->StatusApplicationControl->InvTypeCode = 'TR';
$asm->AvailStatusMessage->StatusApplicationControl->RatePlanCode = 'BAR';

$arr = array(
    'POS' => $pos
    'AvailStatusMessages' => $asm
);

$xml = "
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> 
    <SOAP-ENV:Body xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
        <OTA_HotelAvailNotifRQ xmlns='http://www.opentravel.org/OTA/2003/05' Version='1.0' TimeStamp='2005-08-01T09:30:47+08:00' EchoToken='echo-abc123'>
            <POS>
                <Source>
                    <RequestorID Type='22' ID='$id'/>
                </Source>
            </POS>
            <AvailStatusMessages HotelCode='$hc'>
                <AvailStatusMessage>
                    <StatusApplicationControl Start='2010-01-01' End='2010-01-14' InvTypeCode='A1K' RatePlanCode='GLD'/>
                    <RestrictionStatus Restriction='Departure' Status='Close' />
                </AvailStatusMessage>
            </AvailStatusMessages>
        </OTA_HotelAvailNotifRQ> 
    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>";

So basically I have tried all the possible ways... that I could think of to send this to the call and make it work.

Anyone has any idea how to proper do this? I really need help in here...

What I'm trying to do is this: https://siteminder.atlassian.net/wiki/pages/viewpage.action?pageId=2048374#space-menu-link-content

Thanks in advance.



Solution 1:[1]

Do something like this, it's working for me:

$params = array(      
                'Target' => "Test",
                'Version' => "1.0",
                'POS' => array(
                    'Source' => array(
                        'RequestorID' => array(
                            'ID' => 'test',
                            'MessagePassword' => 'test',
                        ),
                    ),
                ),
                'Criteria' => array(
                    'Criterion' => array(
                        'Address' => array(
                            'CountryName' => array(
                                'Code' => 'US',
                            ),
                        ),
                    ),
                )
            );
            $result = $client->HotelAvailNotif($params);
pre_d($result);

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <OTA_HotelAvailNotifRQ  Target="Test" xmlns="http://www.test.com/test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0">
            <POS>
                <Source>
                    <RequestorID ID="test" MessagePassword="test" />
                </Source>
            </POS>
            <Criteria>
                <Criterion>
                    <Address>
                        <CountryName Code="US"></CountryName>
                    </Address>
                </Criterion>
            </Criteria>
        </OTA_HotelAvailNotifRQ >
    </s:Body>
</s:Envelope>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 סטנלי גרונן