Wssecurity肥皂电话

时间:2013-11-20 15:37:00

标签: php soap wsse

我想创建一个使用Wssecurity的soap调用。

我收到错误InvalidSecurity

任何人都可以通过这个肥皂电话来帮助我。

我需要的是。

    <soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken wsu:Id="UsernameToken-19" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:Username>##USERNAME##</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">##PASSWORD##</wsse:Password>
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>




    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:scr="http://product.products.com/">
    <soapenv:Header>
     <!-- Header must contain valid authentication token -->
    </soapenv:Header>
    <soapenv:Body>
    <scr:product>
    <productRequest>
    <assigneeIdentifier>USER_ID</assigneeIdentifier>
    <product1></product1>
    <product2></product2>
    <productIdentifier>GROUP_ID</productIdentifier>
    <name></name>
    <productType></productType>
    </productRequest>
    </scr:product>
    </soapenv:Body>
    </soapenv:Envelope>

我在php中的代码

肥皂调用的选项

  $opts = array(
        'ssl' => array('ciphers'=>'RC4-SHA')
    );
    ini_set( "soap.wsdl_cache_enabled", "0" );
    $client = new SoapClient(
        'Address to wsdl',
        array ( "encoding"=>"ISO-8859-1",
        'stream_context' => stream_context_create($opts),
        "trace"=>1,
        "exceptions"=>0,
        "connection_timeout"=>2000   
        )
    );

设置soap标头

    $header1['id'] = 'UsernameToken-19';
    $header1['UsernameToken']['Username'] = 'username';
    $soapheader1 = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd',
            'Security',
            $header1);

    $header2['type']= 'PasswordText';
    $header2['UsernameToken']['Password'] = 'password';
    $soapheader2 = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText',
            'Security',
            $header2);

创建soap标题

    $client->__setSoapHeaders(array($soapheader1,$soapheader2));

设置请求

    $productRequest['assigneeIdentifier'] = "50000";
    $productRequest['productId1'] = '';
    $productRequest['productId2'] = '';
    $productRequest['productIdentifier'] = "6000";
    $productRequest['name'] = $form['name'];
    $productRequest['productype'] = $form['type'];


    $product['product']['productRequest'] = $productRequest;
    $params['body'] = $product; 

发送请求

     $results = $client->product($params);

0 个答案:

没有答案