php soapclient无法处理消息,因为内容类型为text / xml; charset = utf-8不是预期的类型application / soap + msbin1。 (HTTP)

时间:2015-12-11 03:20:02

标签: php soap soap-client

我正在尝试使用PHP的soapclient连接到Microsoft服务生成的WSDL。我可以很好地连接,甚至可以恢复类型。但是响应不符合预期的编码。我的代码是:

try {
    $options = array(
            'soap_version' => SOAP_1_1
        ); 

    $url="[web-url]/ReceiveNoteService.svc?wsdl";
    $method = "ReceiveNote";
    $error=0;
    $client = new SoapClient($url, $options);
} catch (Exception $e) {
    echo "<h2>Exception Error!</h2>";
    echo $e->getMessage();
}

echo '<pre>';
print_r($client->__getTypes());
echo '</pre>';

$content = array('FileName' => $name, 'DocumentTypeID' => '1', 'Description' => date("Y-m-d h:i:s"), 'DocumentBody' => unpack("N*",$contentData));

$noteData = array('AuthenticateUserName' => $userName,
                  'AuthenticatePassword' => $userPass,
                  'FileNumber' => $orderId['closingIntegrationId'],
                  'NoteSubject' => 'Uploaded file name: '.$name,
                  'NoteBody' => 'File '.$name.' added on '.date("Y-m-d h:i A"),
                  'Documents' => $content);

try { 
    $info = $client->$method($noteData);
} catch (SoapFault $fault) { 
    $error = 1;
}

if($error==1) {
    $xml = $fault->faultstring.' ('.$fault->faultcode.')';
}else{
    $xml = $info;
}

echo "results: <br/>";
print_r($xml);
echo '<br/>';
die();

我收到的回复是:

Array
(
    [0] => int char
    [1] => duration duration
    [2] => string guid
    [3] => struct ReceiveNoteData {
 int CoordinatorTypeID;
 int CurativeID;
 ReceiveCurativeTypeEnum CurativeType;
 ArrayOfReceiveNoteDocument Documents;
 string FileNumber;
 string NoteBody;
 string NoteSubject;
 int ToCoordinatorID;
}
    [4] => string ReceiveCurativeTypeEnum
    [5] => struct ArrayOfReceiveNoteDocument {
 ReceiveNoteDocument ReceiveNoteDocument;
}
    [6] => struct ReceiveNoteDocument {
 string Description;
 base64Binary DocumentBody;
 int DocumentTypeID;
 string FileName;
 boolean InternalOnly;
}
    [7] => struct ReceiveNoteResponse {
 string Message;
 ReceiveNoteResponseCode ResponseCode;
}
    [8] => string ReceiveNoteResponseCode
    [9] => struct ReceiveNote {
 ReceiveNoteData NoteData;
}
    [10] => struct ReceiveNoteResponse {
 ReceiveNoteResponse ReceiveNoteResult;
}
)

results:
Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+msbin1'. (HTTP)

我不确定如何更改为application/soap+msbin1。我试过使用肥皂版本1.1和1.2。我已经检查了我在Google上找到的所有结果,但没有任何效果,甚至更改了返回的错误。我累了,我可以帮忙。所以任何帮助都表示赞赏。哈哈〜

0 个答案:

没有答案