我应该从我的角应用程序发送HTTP post请求到另一台服务器:
x86_64-1.0.3
$http({
method: 'POST',
url:'www.example.com/SearchHotel.php',
data:
'<?xml version="1.0" encoding="utf-8"?>
<Service_SearchHotel>
<AgentLogin>
<AgentId>xxx</AgentId>
<LoginName>xxxx</LoginName>
<Password>xxx</Password>
</AgentLogin>
<SearchHotel_Request>
<PaxPassport>MA05110184</PaxPassport>
<DestCountry>WSASTH</DestCountry>
<DestCity>WSASTHBKK</DestCity>
<HotelId InternalCode=""></HotelId>
<Period checkIn="2017-10-26" checkOut="2017-10-28" />
<RoomInfo>
<AdultNum RoomType="Twin">2</AdultNum>
<ChildAges />
</RoomInfo>
<flagAvail>Y</flagAvail>
</SearchHotel_Request>
</Service_SearchHotel>'
,
headers: {
'Content-Type' :'multipart/form-data',
'Content-Disposition': 'form-data',
**'name':"requestXML",**
'Accept':'application/xml',
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Methods':'GET,PUT,POST,DELETE',
'Access-Control-Allow-Headers':'Content-Type'
}
}).then(function(error,response){
if (error) {
console.log(error);
}else{
console.log(response)
}
数据上的servar必须使用哪个requestXML正常返回,但在我的应用中总是返回:
google postman
并给我"<?xml version="1.0" encoding="utf-8"?>↵<Service_SearchHotel>↵ <SearchHotel_Response>↵ <Error>↵ <ErrorDescription>Invalid Tag XML</ErrorDescription>↵ </Error>↵ </SearchHotel_Response>↵</Service_SearchHotel>↵"
。我应该如何将Invalid Tag XML
传递给我的帖子数据,因为在我将此部分添加到邮递员之前我确定了这个问题,它返回了同样的错误。
如果有任何帮助可以节省我这么多时间
PS:
requestXML
这部分内容是我从邮递员那里复制的,然后才尝试'Content-Disposition': 'form-data',
**'name':"requestXML",**
和数据:'Content-Type' :'application/xml',
并获得同样的错误
答案 0 :(得分:0)
也许请看一下:https://groups.google.com/forum/#!topic/rest-assured/QPjllwl8ins
基本上,您需要指定内容边界并将该边界放在data
$http({
method: 'POST',
url:'www.example.com/SearchHotel.php',
data:
'------MuhUniqueIdX8nBO7q27yQ1JNb
<?xml version="1.0" encoding="utf-8"?>
<Service_SearchHotel>
<AgentLogin>
<AgentId>xxx</AgentId>
<LoginName>xxxx</LoginName>
<Password>xxx</Password>
</AgentLogin>
<SearchHotel_Request>
<PaxPassport>MA05110184</PaxPassport>
<DestCountry>WSASTH</DestCountry>
<DestCity>WSASTHBKK</DestCity>
<HotelId InternalCode=""></HotelId>
<Period checkIn="2017-10-26" checkOut="2017-10-28" />
<RoomInfo>
<AdultNum RoomType="Twin">2</AdultNum>
<ChildAges />
</RoomInfo>
<flagAvail>Y</flagAvail>
</SearchHotel_Request>
</Service_SearchHotel>
------MuhUniqueIdX8nBO7q27yQ1JNb'
,
headers: {
'Content-Type' :'multipart/form-data; boundary=------MuhUniqueIdX8nBO7q27yQ1JNb',
另请参阅使用AngularJS表单数据API,how to upload file using Angularjs, multipart/form-data