我花了几个小时来解决这个问题,但仍然无法解决这个问题。如果我使用Postman向具有相同请求主体的API发送请求,它可以正常工作,但在代码中它给了我无效的XML'错误。
任何人都知道我在这里做错了什么?
代码段
const host = "https://staging.familytreedna.com/ftdnawebservice/lifelinehometest.asmx?wsdl";
Soap.createClient(host, function(err, client){
client.on('soapError', function(err, eid){
console.log("REQUEST ERROR", err);
});
client.on('request', function(xml, eid){
console.log("REQUEST SOAP", xml);
});
const _requestParam = {......};
var result1 = client.LifelineHomeTestWS.LifelineHomeTestWSSoap.Create({
message: _requestParam,
});
});
请求正文
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<soap:Body>
<Create xmlns="http://tempuri.org/">
<message>
<Authentication>
<UserName>USERNAME</UserName>
<Password>PASSWORD</Password>
</Authentication>
<Order>
<FtdnaOrderId>LH100031</FtdnaOrderId>
<RsOrderId>494648361009</RsOrderId>
<FirstName>Saud</FirstName>
<MiddleName></MiddleName>
<LastName>S.</LastName>
<FamilySurname>S.</FamilySurname>
<Address>abc </Address>
<City>Austin</City>
<State>TX</State>
<Zip>78704</Zip>
<Country>USA</Country>
<PhoneNumber>1341324123</PhoneNumber>
<CustomerEmail>mail@email.com</CustomerEmail>
<TotalPrice>79</TotalPrice>
<Gender>Male</Gender>
<Products>
<Product>
<Name>PRODUCT NAME</Name>
</Product>
</Products>
<Password>PASSWORD</Password>
</Order>
<Date>2018-05-21T19:16:31-04:00</Date>
</message>
</Create>
</soap:Body>
</soap:Envelope>
请求标题
响应