dongwei4103 2018-08-04 01:00
浏览 54

将XML发送到Soap Web服务php

I am really new to Web Services and xml and I'am Having problems sending xml to a web server

I' am using SoapCliente Php class

$client = new SoapClient($wsdlUrl, $soapClientOptions);

I'm not having any problem sending strings

$param = ["key" => "somekey"];

var_dump($client->somemethod($parms));

But, I am having probles sending xml data as is requered on the web service documentation

@WebParam(name = "xml") byte[] xml);

On the getTypes method:

var_dump($client->__getTypes());

Is specified in this way:

base64Binary xml

So I first stored the xml file as a string variable and then i tried:

$xmlstring = "some xml";    
$xmltosend = unpack('C*', $xmlstring);
var_dump($client->somemethod($xmltosend));

And:

$xmlstring = "some xml";   
$xmltosend = base64_encode($xmlstring);
var_dump($client->somemethod($xmltosend));

The Web Service always send a response acording to the data so if the send was correct i will get some succes xml data. In both cases I get this error:

FILES SENT NOT COMPLY WITH THE ESTABLISHED SPECIFICATIONS: EXTENSION, CODIFICATION

The xml format that i am sending is provided as a test example by the web service's documentation so i think the xml is Ok, so I am clueless of what I am missing.

Edit

This is exactly how the params are excected on the documentation

@WebMethod
@WebResult(name = "RespuestaRecepcionComprobante")
public RespuestaSolicitud validarComprobante(@WebParam(name = "xml") byte[] 
xml);

So i just sended the xml string and it worked

$param = ["xml" => $xmlstring];
var_dump($client->validarComprobante($param));

It's ok to send the data like this? The web service read the xml and send me an Ok response I also expect an xml response but I dont know how to catch it

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题