无法通过代码调用soap请求 [英] Unable to call soap request through code

查看:255
本文介绍了无法通过代码调用soap请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过邮递员调用TCS的肥皂,它在那里工作正常,当我试图通过代码调用它时出现这个错误:



服务器无法处理请求.--->根级别的数据无效。第1行,第1位



我有什么试过:



I have trying calling a soap of TCS through postman and it works fine there the only problem occurs when i am trying to call it through code getting this error:

"Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1"

What I have tried:

This is my XML: 
 <pre lang="HTML">
      define('tcs', "http://track.tcs.com.pk/trackingaccount/track.asmx");
       $xml = '<?xml version="1.0" encoding="utf-8"?>';
       $xml.= '<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
       $xml.=   '<SOAP-ENV:Body>';
       $xml.=     '<DataSet_DeliveryDetails_CN xmlns="http://tempuri.org/">';
       $xml.=           '<CN>30074955506</CN>';
       $xml.=           '</DataSet_DeliveryDetails_CN>';
       $xml.=         '</SOAP-ENV:Body>';
       $xml.=       '</SOAP-ENV:Envelope>';





这是我的卷曲请求:



$ c = curl_init();

curl_setopt($ c,CURLOPT_URL,tcs);

curl_setopt($ c,CURLOPT_RETURNTRANSFER,1) ;



curl_setopt($ c,CURLOPT_POST,1);

curl_setopt($ c,CURLOPT_POSTFIELDS,array('xml'=> $ xml));

curl_setopt($ c,CURLOPT_HTTPHEADER,数组('Content-Type = application / soap + xml','charset = utf-8'));

$ result = curl_exec($ c);

dd($ result);



This is my curl request :

$c = curl_init();
curl_setopt($c, CURLOPT_URL, tcs);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, array('xml' => $xml));
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type=application/soap+xml', 'charset=utf-8'));
$result = curl_exec($c);
dd($result);

推荐答案

xml ='<? xml version = 1.0 encoding = utf-8 ?> ';
xml = '<?xml version="1.0" encoding="utf-8"?>';


xml。='< SOAP-ENV:Envelope xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance xmlns:xsd = http://www.w3.org/2001/XMLSchema xmlns:soap = http://schemas.xmlsoap.org/soap/envelope/ > ';
xml.= '<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';


xml。='< SOAP-ENV:正文 > ';
xml.= '<SOAP-ENV:Body>';


这篇关于无法通过代码调用soap请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆