我必须在带有参数的Axis2服务器上进行SOAP调用,但是我遇到了很多问题,我在SOAPUI上做了这个并且运行正常。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Seguridad>
<usuario>0000000000</usuario>
<password>9FDB5D2R4J62755C7DA205S52D8G4H36D4CRCB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</soapenv:Header>
<soapenv:Body>
<ws:enviaCONVOL xmlns:ws="http://ws.convol/">
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDmyYTc3YTAyZjM2YT8lZDc4MzgwOTZhY2Y0YTM1MDg3Wg==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDmyYTc3YTAyZjM2YT8lZDc4MzgwOTZhY2Y0YTM1MDg3Wg==</arg3>
</ws:enviaCONVOL>
</soapenv:Body>
</soapenv:Envelope>
我需要在PHP和MTOM中使用soap,而arg2是来自zip文件的CID。
当我尝试实现标头并将SOAP调用发送到服务器时,始终会收到“内部错误”或“未知内容编码”。我遇到了标题和调用的正确实现方面的一些问题,我需要像代码一样发送。
我用PHP得到的东西:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.convol/"><SOAP-ENV:Body><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Seguridad>
<usuario>0000105847</usuario>
<password>9FDBDE265822755C7DA2058053B61580736ECB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</soapenv:Header>
<soapenv:Body>
<ws:enviaCONVOL xmlns:ws="http://ws.convol/">
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDQyYTc3YTAyZjM2YThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDQyYTc3YTAyZjM2YThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg3>
</ws:enviaCONVOL>
</soapenv:Body>
</soapenv:Envelope></SOAP-ENV:Body></SOAP-ENV:Envelope>
我在PHP上有这个
try{
$client=new SoapClient('https://www.convolmiscelaneapruebas.pemex.com/ServiciosCVWEB/ServicioEnviaCONVOLService/ServicioEnviaCONVOLService.wsdl',array( 'trace' => 1, 'exceptions' => 0 ));
$header = '<SOAP-ENV:Header>
<Seguridad>
<usuario>0000000000</usuario>
<password>9FDBDE265822755C50dHD5D33B61580736ECB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</SOAP-ENV:Header>';
$xml = '<ns1:enviaCONVOL>
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDQyYTc3YTAyZddd5IMKYThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDQyYTdnHD90D3185D4MzgwOTZhY2Y0YTM1MDg3Ng==</arg3>
</ns1:enviaCONVOL>
';
$args = array(new SoapVar($xml, XSD_ANYXML));
$res = $client->__soapCall('enviaCONVOL', $args);
echo "<hr>Last Request<br>";
echo "<pre>", htmlspecialchars($client->__getLastRequest()), "</pre>";
print_r($res);
}catch (SoapFault $fault){
echo "SOAPFault: ".$fault->faultcode." - ".$fault->faultstring.' - '.$fault->getMessage();
}
我无法将标题放在正确的位置......
答案 0 :(得分:0)
我使用了NuSoap
$wsdl = "https://www.convolmiscelaneapruebas.pemex.com/ServiciosCVWEB/ServicioEnviaCONVOLService/ServicioEnviaCONVOLService.wsdl";
$client = new nusoap_client($wsdl,TRUE);
$header =
"<Seguridad>
<usuario>0000000000</usuario>
<password>4e671bf08913d677c56359262117c8e67a5507b165f727288a487040bf2a1780</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>";
$operation = array('arg0' => '2014-12-31',
'arg1' => '11:48:46',
'arg2'=>'12095866ae89b7dbcd44640189c57e185918192739040eb52ba5b==',
'arg3'=>'ZmU5866axMzc3ZDQyJmdAyZjM2YThlZDb7dbcd446401YTM1Mg3Ng=='
);
$client->setHeaders($header);
$res = $client->call('enviaCONVOL',$operation);