如何将xml doc作为字节数组发送到soap服务?

时间:2018-03-22 09:03:23

标签: php .net xml web-services soap

我有一个XML,我使用下面的byteArray代码转换为PHP

$xmlStr = file_get_contents('demo2.xml'); // read file to string
$byte_array = unpack('C*', $xmlStr); 
echo  implode(',', $byte_array) ; 

我需要将上面的字节数组传递给文件标记中的下面soap信封。 后端网络服务已写在.net

  <Envelope xmlns="http://example/soap/envelope/">
        <Body>
            <sample  xmlns="http://example.org/">
                <User>[string?]</User>
                <Password>[string?]</Password>
                <File>[anyType?]</File>
            </sample>
        </Body>
    </Envelope>

我正在使用wizdler拨打服务电话,但我最终收到了以下错误:

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter  
 The InnerException message was 'Element File from namespace http://example.org/ cannot have child contents to be deserialized as an object. 

Please use XmlNode[] to deserialize this pattern of XML.'.  Please see InnerException for more details.

如何在上述场景中将xml文件作为字节数组发送?

1 个答案:

答案 0 :(得分:0)

我也在寻找它,我找到了解决方案。 我想你可以尝试
How to send a File(base64Binary) in web service request using SOAP UI ?