如何通过安全规范发出Soap请求

时间:2018-10-14 17:48:24

标签: php web-services soap ws-security

我是使用XML和Soap与Web服务集成的初学者,并且在使用安全规范开发请求时遇到困难。

根据集成文档,申请书必须包含以下安全规范:

数字签名

密码学

我的SSL证书:https://www.ssllabs.com/ssltest/analyze.html?d=www.apasp.net.br

以下是我当前的Soap请求:

$xmlRequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w="http://www.cip-bancos.org.br/ARQ/WSCC011.xsd" xmlns:s="http://www.cip-bancos.org.br/ARQ/ASCC011.xsd" xmlns:wt="http://www.cip-bancos.org.br/schemas/WSTIPOS.xsd">
                <soapenv:Header>
                </soapenv:Header>
                <soapenv:Body>
                <w:WSCC011Request>
                    <w:CabecalhoReq>
                        <wt:NumCtrlEmis></wt:NumCtrlEmis>
                        <wt:ISPBEmissor></wt:ISPBEmissor>
                        <wt:ISPBDestinatario></wt:ISPBDestinatario>
                        <wt:DtHrEmis></wt:DtHrEmis>
                        <wt:DtRef></wt:DtRef>
                        <wt:DomSis></wt:DomSis>
                        <wt:NUop></wt:NUop>
                    </w:CabecalhoReq>
                    <w:Corpo>
                        <w:ASCC011>
                            <s:Grupo_ASCC011_Consigrio>
                                <IdentdPartAdmdo></IdentdPartAdmdo>
                                <NumCtrlConsigrio></NumCtrlConsigrio>
                                <CNPJBaseEnte></CNPJBaseEnte>
                                <NumConsigrioEnte></NumConsigrioEnte>
                                <NumDigtConsigrioEnte></NumDigtConsigrioEnte>
                                <Grupo_ASCC011_Consignc>
                                    <NumCPFServdr></NumCPFServdr>
                                    <IdentcServdr></IdentcServdr>
                                    <IdentcOrgao></IdentcOrgao>
                                    <CNPJBaseOrgaoPagdr></CNPJBaseOrgaoPagdr>
                                    <IdentcEsp></IdentcEsp>
                                    <TpParcmnt></TpParcmnt>
                                    <QtdTotParcl></QtdTotParcl>
                                    <DiaVencParcl></DiaVencParcl>
                                    <DtIniAvebc></DtIniAvebc>
                                    <DtFimAvebc></DtFimAvebc>
                                    <VlrParcl></VlrParcl>
                                    <VlrTotAvebc></VlrTotAvebc>
                                    <NumOpConsigncConsigrio></NumOpConsigncConsigrio>
                                </Grupo_ASCC011_Consignc>
                            </s:Grupo_ASCC011_Consigrio>
                        </w:ASCC011>
                    </w:Corpo>
                </w:WSCC011Request>
                </soapenv:Body>
                </soapenv:Envelope>';
        try {
            $client = new SoapClient('https://www.hext.portaldoconsignado.org.br/ws/WSCC011', array('trace' => 1));
            $soapBody = new \SoapVar($xmlRequest, \XSD_ANYXML);
            $return = $client->__soapCall('WSCC011', array());

            echo '<pre>' . var_export($return, true) . '<pre>';
        } catch(Exception $e) {
            echo(htmlentities($client->__getLastResponse()));
        }

0 个答案:

没有答案