php - 如何使用安全规范发出 Soap 请求
问题描述
我是使用 XML 和 Soap 与 Web 服务集成的初学者,我在使用安全规范开发我的请求时遇到了困难。
根据集成文档,请购单必须包含以下安全规范:
电子签名
- 签名算法:RSA-SHA256 ( http://www.w3.org/2001/04/xmldsigmore#rsa-sha256 )
- 签名规范化:C14N-exc ( http://www.w3.org/2001/10/xml-exc-c14n# )
- 摘要算法:SHA256 ( http://www.w3.org/2001/04/xmlenc#sha256 )
- 签名目标:
- 时间戳(命名空间: http: //docs.oasis-open.org/wss/2004/01/oasis-200401-wss-security-utility-1.0.xsd)
- 正文(命名空间:http: //schemas.xmlsoap.org/soap/envelope/)
- 发行人的公钥通过 IssuerSerial 进行通信(命名空间:http ://www.w3.org/2000/09/xmldsig# )
密码学
- 对称编码算法:3DES-CBC
- 密钥传输算法:RSA-OAEP
- 通过 IssuerSerial 通信的接收方公钥
- 加密目标:
- 正文(命名空间:http: //schemas.xmlsoap.org/soap/envelope/)
我的 SSL 证书:https ://www.ssllabs.com/ssltest/analyze.html?d=www.apasp.net.br
以下是我当前的肥皂请求:
$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()));
}
解决方案
推荐阅读
- xtermjs - 如何在 xtermjs 中设置缓冲区的大小?
- python - 从不同的脚本登录到同一个文件?
- python - 网络抓取时如何维护与同一主机的多个会话?
- amazon-web-services - 如何使用 Amazon Cognito Identity Js 在 Aws Cognito 中实施 RBAC
- java - 如何将 Java 字符串解析为 YAML 中的文字块
- php - PHP mysql while循环在foreach循环中重复
- javascript - 将新对象添加到多维数组
- javascript - 仅在溢出时才在悬停时选择字幕
- r - 将多维数组读入R
- typescript - 向 Parse.User 扩展/添加方法