Проблема в Генерировании ниже, при попытке со всеми видами входных данных в WS02 policy.xml.Kindly помочь в генерации ниже части в запросе веб-сервиса.
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIIDUjCCAjqgAwIBAgIIBX96VBJzA1QwDQYJKoZIhvcNAQEFBQAwWjERMA8GA1UEAxMIUEdXU3Vi
Q0ExEDAOBgNVBAoTB1NpZW1lbnMxEzARBgNVBAcTCkJyYXRpc2xhdmExETAPBgNVBAgTCFNsb3Zh
a2lhMQswCQYDVQQGEwJTSzAeFw0wNjAxMDQxNTExMzBaFw0wODAxMDQxNTIxMzBaMFsxEjAQBgNV
BAMTCUNhcm1lblNpbTEQMA4GA1UEChMHU2llbWVuczETMBEGA1UEBxMKQnJhdGlzbGF2YTERMA8G
A1UECBMIU2xvdmFraWExCzAJBgNVBAYTAlNLMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCc
rUHuWD+sfU+PS+vYe/wwAOWlpTqpcRhKwXTlhtfekQSEz/jzqWhfRuPzNil16QFOdPZg5M0OusI3
ln239La5ZpkTSvCc5LrNbj4SvJu2cbc1UYU1BAQCipxs6kG1biYd3nWqpGum8nESybLSPHActZ/1
DKVauBXEWFSKdazUkQIDAQABo4GeMIGbMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMDsG
A1UdJQQ0MDIGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYBBQUHAwQGCCsGAQUFBwMFBggrBgEFBQcD
BzAdBgNVHQ4EFgQURQJ7qpFi7doKbZvRkDIf4My3LrIwHwYDVR0jBBgwFoAUtbaYUw+qe+iV0ruq
WFVWZDJdB4kwDQYJKoZIhvcNAQEFBQADggEBAI3xvGKw8nsZdyVh29ON+mlfsv2LERT+zqeNSsuE
Pno58V+HFn28QaPJX7CwNsfRS0txA7gbmAM5BgUPXVWzqjgXp0HeWj1qzM5yuawLzBP9d7thWkrK
ZOr7vWPMKFkhiw37WFaSot6HGVCU+KrMxL2hteIhLNGKLKQiKVIoUpAKgzuGe9PBwaxD1JxsBSKs
x8zigoPAlMhRdktg1lYI7/jKgEXPK9TfNmP1bQGErP88j4aw3fC2DQiOaewjQlCV7BaZ5ZdYLlj8
IV1BmGukpJZvTUj6/T6ui5CrAngiGEL17NNWkvunn4Vrie038D5U3NK31b/uKdMHiwmb1iu/Ykc=</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue>
<ds:RSAKeyValue>
<ds:Modulus>nK1B7lg/rH1Pj0vr2Hv8MADlpaU6qXEYSsF05YbX3pEEhM/486loX0bj8zYpdekBTnT2YOTNDrrC
N5Z9t/S2uWaZE0rwnOS6zW4+ErybtnG3NVGFNQQEAoqcbOpBtW4mHd51qqRrpvJxEsmy0jxwHLWf
9QylWrgVxFhUinWs1JE=</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
Это $ xml, не умеющий вставлять мыльные заголовки. $ client = new WSClient (array («wsdl» => «/ home / sps_mtnc_dev / Preetham / CBSInterface_BusinessMgr.wsd l», «policy» => $ policy, «securityToken» => $ xml)). Результат мы не можем увидеть сертификат X509
Как это?:
<?php
include('File/X509.php');
$cert = '-----BEGIN CERTIFICATE-----
MIIDITCCAoqgAwIBAgIQT52W2WawmStUwpV8tBV9TTANBgkqhkiG9w0BAQUFADBM
MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0xMTEwMjYwMDAwMDBaFw0x
MzA5MzAyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw
FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
gYEA3rcmQ6aZhc04pxUJuc8PycNVjIjujI0oJyRLKl6g2Bb6YRhLz21ggNM1QDJy
wI8S2OVOj7my9tkVXlqGMaO6hqpryNlxjMzNJxMenUJdOPanrO/6YvMYgdQkRn8B
d3zGKokUmbuYOR2oGfs5AER9G5RqeC1prcB6LPrQ2iASmNMCAwEAAaOB5zCB5DAM
BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl
LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF
BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw
Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0
ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF
AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp
ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le
IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q==
-----END CERTIFICATE-----';
$x509 = new File_X509();
$x509->loadX509($cert);
$pubKey = $x509->getPublicKey();
$xml = '<KeyInfo><X509Data><X509Certificate>';
$xml.= preg_replace('#-.*-#', '', $cert);
$xml.= '</X509Certificate></X509Data><KeyValue>';
$xml.= $pubKey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_XML);
$xml.= '</KeyValue></KeyInfo>';
echo preg_replace('#(</?)#', '$1ds:', $xml);
Оно использует phpseclib и требует, чтобы вы предоставили сертификат X.509.
Here is the script and policy.xml. Not able to generate formed request in soap request.Kindly assit
<?php
try {
$my_cert = ws_get_cert_from_file("/home/sps_mtnc_dev/Preetham/keys/bob_cert.cert");
$my_key = ws_get_key_from_file("/home/sps_mtnc_dev/Preetham/keys/bob_key.pem");
$rec_cert = ws_get_cert_from_file("/home/sps_mtnc_dev/Preetham/keys/alice_cert.cert");/*Load policy file*/
$policy_xml = file_get_contents("/home/sps_mtnc_dev/Preetham/keys/policy.xml");
//$policy = new WSPolicy(array("security"=>array("useUsernameToken" => TRUE, "includeTimeStamp" => TRUE)));
$policy = new WSPolicy($policy_xml);
include('/home/sps_mtnc_dev/wso2/wsf-master/php/scripts/phpseclib0.3.10/File/X509.php');
$cert = '-----BEGIN CERTIFICATE-----
MIIDITCCAoqgAwIBAgIQT52W2WawmStUwpV8tBV9TTANBgkqhkiG9w0BAQUFADBM
MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0xMTEwMjYwMDAwMDBaFw0x
MzA5MzAyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw
FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
gYEA3rcmQ6aZhc04pxUJuc8PycNVjIjujI0oJyRLKl6g2Bb6YRhLz21ggNM1QDJy
wI8S2OVOj7my9tkVXlqGMaO6hqpryNlxjMzNJxMenUJdOPanrO/6YvMYgdQkRn8B
d3zGKokUmbuYOR2oGfs5AER9G5RqeC1prcB6LPrQ2iASmNMCAwEAAaOB5zCB5DAM
BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl
LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF
BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw
Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0
ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF
AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp
ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le
IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q==
-----END CERTIFICATE-----';
$x509 = new File_X509();
$x509->loadX509($cert);
$pubKey = $x509->getPublicKey();
$xml = '<KeyInfo><X509Data><X509Certificate>';
$xml.= preg_replace('#-.*-#', '', $cert);
$xml.= '</X509Certificate></X509Data><KeyValue>';
$xml.= $pubKey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_XML);
$xml.= '</KeyValue></KeyInfo>';
echo preg_replace('#(</?)#', '$1ds:', $xml);
$sec_token = new WSSecurityToken(array("privateKey" => $my_key, "certificate" => $my_cert));
$client = new WSClient(array("wsdl"=>"/home/sps_mtnc_dev/Preetham/CBSInterface_BusinessMgr.wsdl", "policy" => $policy, "securityToken" => $sec_token));
//$client = new WSClient(array("wsdl"=>"/home/sps_mtnc_dev/Preetham/prov-gw-hlr_subscriber-4.5.3.wsdl"));
printf("WSDL loaded \n");
//$client = new WSClient(array("useSOAP" => TRUE,"policy" => $policy,"securityToken" => $sec_token));
printf("Response = %s \n", $client);
$proxy = $client->getProxy();
//printf("Proxy = %s \n",$proxy);
printf("getProxy done \n");$SessionEntity = array("Name" => 10001, "Password" => "qBnsbLtbFeBA1rBaPtuwXg==", "RemoteAddress" => 172123);
$RequestHeader = array("CommandId" => "NewSubscriber", "Version" => 1, "TransactionId" => 1234, "SequenceId" => 1, "RequestType" => "Event", "SessionEntity" => $SessionEntity, "SerialNo" => 1234);
$Subscriber = array("Lang" => 1234, "PaidMode" => 1234, "MainProductID" => 1234, "IMSI" => 1234);
$NewSubscriberRequest = array("SubscriberNo" => 1234, "Subscriber" => $Subscriber);printf("Input message ready \n");
$resMessage = $proxy->NewSubscriber(array("NewSubscriberRequest" => $xml));
printf("Input message ready = %s \n", $resMessage);
printf("Response = %s \n", $resMessage->str);
} catch (Exception $e) {
if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->Reason);
} else {
printf("Message = %s\n",$e->getMessage());
}
}
?>policy.xml :
<wsp:Policy wsu:Id="SgnOnlyAnonymous" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsse11="http://docs.oasis-open.org/wss/2005/xx/oasis-2005xx-wss-wssecurity-secext-1.1.xsd">
<wsp:ExactlyOne>
<wsp:All>
<sp:AsymmetricBinding>
<wsp:Policy>
<sp:InitiatorToken>
<wsp:Policy>
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always">
<wsp:Policy>
<sp:RequireKeyIdentifierReference/>
<sp:RequireIssuerSerialReference/>
<sp:RequireEmbeddedTokenReference/>
<sp:WssX509V1Token10/>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always">
<wsp:Policy>
<sp:RequireKeyIdentifierReference/>
<sp:RequireIssuerSerialReference/>
<sp:RequireEmbeddedTokenReference/>
<sp:WssX509V1Token10/>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:RecipientToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic128Rsa15/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
<sp:OnlySignEntireHeadersAndBody/>
</wsp:Policy>
</sp:AsymmetricBinding>
<sp:SupportingTokens>
<sp:Body/>
</sp:SupportingTokens>
<sp:SignedParts>
<sp:Body/>
</sp:SignedParts></wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>