是否有人知道如何更正或是否有此错误的解决方案?>
HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-8;action="urn:HealthCareServiceWCF/GetClaimsList"' was not the expected type 'application/soap+msbin1'. Cache-Control: private Server: Microsoft-IIS/7.5 Set-Cookie: ASP.NET_SessionId=ilvagsgvofc2r5jclkvjtysv; path=/; HttpOnly X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Fri, 27 Jun 2014 22:26:03 GMT Content-Length: 0
这是我的代码。
<?php //-->
类LocalSoapClient扩展SoapClient { protected $ _xml = null;
public function __construct($wsdl, $options, $xml)
{
$this->_xml = $xml;
parent::__construct($wsdl, $options);
}
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
ob_start();
$request = $this->_xml;
return parent::__doRequest($request, $location, $action, $version, $one_way);
ob_end_clean();
}
}
function mcrypts_encrypt($encrypted)
{
//Padding 6/25/2014
$pad = 16 - (strlen($encrypted) % 16);
$encrypted = $encrypted . str_repeat(chr($pad), $pad);
//Encrypt//Decode
$iv = base64_decode('...');
$key = base64_decode('...');
$plaintext = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv );
//Return encrypted Data
return base64_encode($plaintext);
}
$portal = 'CaregiverPortalService';
$userName = '...';
$password = '...';
$passwordnew = '...';
$url = "https://webapp.healthcaresynergy.com:8002/demoalpha/HealthCareServiceWCF.svc?singleWsdl";
$option = array('trace' => 1 );
$xml = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">'.
'<soap:Header/>'.
'<soap:Body>'.
'<Login>'.
'<userName>'.$userName.'</userName>'.
'<password>'.$password.'</password>'.
'<newPassword>'.$passwordnew.'</newPassword>'.
'</Login>'.
'</soap:Body>'.
'</soap:Envelope>';
$client = new LocalSoapClient($url, $option, $xml);
try
{
$client->Login();
$response = $client->__getLastResponse();
echo 'result';
echo "<br/>";
echo htmlspecialchars($response);
$p = xml_parser_create();
xml_parse_into_struct($p, $response, $vals, $index);
xml_parser_free($p);
echo "Index array\n";
echo('<pre>');
print_r($index);
echo('<pre/>');
echo "\nVals array\n";
//print_r($vals);
//echo $vals[114]['value'];
//$sessiontoken = $vals[114]['value'];
}
catch (SoapFault $fault)
{
echo $client->__getLastRequestHeaders();
echo 'Request : <br/><xmp>',
$client->__getLastRequest(),
'</xmp><br/><br/> Error Message : <br/>',
$fault->getMessage();
echo '<pre>';
print_r ($client);
}
感谢所有愿意提供答案,帮助,建议或观点的人。
答案 0 :(得分:0)
ob_end_clean();
很可能导致问题。从我在代码中看到的内容来看,你根本不需要它。
就这样做:
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
$request = $this->_xml;
return parent::__doRequest($request, $location, $action, $version, $one_way);
}
如果确实需要它,至少在ob_end_clean
之前使用return
,否则它无效:P