views:

81

answers:

1

I am getting a request in the following method but the soap message does not appear to contain the UsernameToken Element:

$policy = new WSPolicy(
    array(
        'useUsernameToken'=>true
    )
);
$security = new WSSecurityToken(
    array(
        'user'=>$username,
        'passwordType'=>'PlainText',
        'password'=>$password
    )
);
// create client in WSDL mode
$client = new WSClient(
    array (
        'wsdl'=>$service_wsdl,
        'to'=>$service_url,
        'policy'=>$policy,
        'securityToken'=>$security,
        'trace'=>1
    )
);
$proxy = $client->getProxy();
$proxy->Ping();

The request that is produced looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <ns1:Ping xmlns:ns1="http://streamlinedsalestax.org/efile"/&gt;
    </soapenv:Body>
</soapenv:Envelope>

You'll notice that the UsernameToken element is completely missing.

A: 

how about this.. added 'security' to WSPolicy

<?php
$policy = new WSPolicy(
    array('security' => array(
        'useUsernameToken'=>true
    ))
);
$security = new WSSecurityToken(
    array(
        'user'=>$username,
        'passwordType'=>'PlainText',
        'password'=>$password
    )
);
// create client in WSDL mode
$client = new WSClient(
    array (
        'wsdl'=>$service_wsdl,
        'to'=>$service_url,
        'policy'=>$policy,
        'securityToken'=>$security,
        'trace'=>1
    )
);
$proxy = $client->getProxy();
$proxy->Ping();
nathan
If I setup the WSPolicy object as you stated then a request never gets generated....and $client->getLastRequest() returns an empty string. I am also seeing: Notice: Undefined variable: payload_node in /home/enterprise/includes/wso2/dynamic_invocation/wsf_wsdl_serialization.php on line 157
dorgan