soapenv:Server.userException -来自 eBay Trading API 的>错误 GetSellingManagerSoldListingsRequest



感谢Vancalar的建议和XML代码(请参阅:eBay Trading API-Delphi中的调用结构(,我制作了如下测试程序:

procedure TForm1.Button1Click(Sender: TObject);
var
sSOAP: String;
sCallName, sSiteID, sVersion: String;
sResponseBody: TStringStream;
xDoc: IXMLDocument;
begin
sCallName := 'GetSellingManagerSoldListingsRequest';
sSiteID := '15';                       // 15 for Australia
sVersion := '945';
sSOAP := '<?xml version="1.0"?>'
+ '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'
+ '  xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
+ '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
+ '  <SOAP-ENV:Header>'
+ '    <NS1:RequesterCredentials xmlns:NS1="urn:ebay:apis:eBLBaseComponents">'
+ '      <eBayAuthToken xmlns="urn:ebay:apis:eBLBaseComponents">' + sToken + '</eBayAuthToken>'
+ '      <NS1:Credentials>'
+ '        <AppId xmlns="urn:ebay:apis:eBLBaseComponents">' + sAppID + '</AppId>'
+ '        <DevId xmlns="urn:ebay:apis:eBLBaseComponents">' + sDevID + '</DevId>'
+ '        <AuthCert xmlns="urn:ebay:apis:eBLBaseComponents">' + sCertID + '</AuthCert>'
+ '      </NS1:Credentials>'
+ '    </NS1:RequesterCredentials>'
+ '  </SOAP-ENV:Header>'
+ '  <SOAP-ENV:Body>'
+ '    <GetSellingManagerSoldListingsRequest xmlns="urn:ebay:apis:eBLBaseComponents">'
+ '      <DetailLevel>ReturnAll</DetailLevel>'
+ '      <ErrorLanguage>en_GB</ErrorLanguage>'
+ '      <Version>945</Version>'
{
+ '      <Search>'
+ '        <SearchType>SaleRecordID</SearchType>'
+ '        <SearchValue>' + '1981' + '</SearchValue>'
+ '      </Search>'
}
+ '    <Archived>false</Archived>'
+ '    <SaleDateRange>'
+ '      <TimeFrom>2018-11-05T17:59:32.939+02:00</TimeFrom>'
+ '      <TimeTo>2018-11-06T23:59:59.940+01:00</TimeTo>'
+ '    </SaleDateRange>'
+ '  </GetSellingManagerSoldListingsRequest>'
+ '</SOAP-ENV:Body>';
objHttpReqResp.URL := 'https://api.ebay.com/wsapi';
sResponseBody := TStringStream.Create();
try
objHttpReqResp.Execute(sSOAP, sResponseBody);
xDoc := TXMLDocument.Create(nil);
xDoc.LoadFromStream(sResponseBody);
xDoc.SaveToFile('XML_Output.txt');
memHTML.Lines.LoadFromFile('XML_Output.txt');
memHTML.Lines.Add('');
except
memHTML.Lines.Add('Error happened!');
memHTML.Lines.Add('');
end;
end;

返回结果为:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

这意味着:

  1. 用户信息有错误(Token/AppID/DevID/CertID(
  2. 或者我的代码有混合了一些参数的问题

有什么建议吗?sToken是卖家的易趣代币,它刚刚从Developer.eBay.com应用。

谢谢。

#程序更新如下:

procedure TForm1.Button1Click(Sender: TObject);
var
sXML: String;
sCallName, sSiteID, sVersion: String;
sResponseBody: TStringStream;
xDoc: IXMLDocument;
sSaleNo: String;
begin
sCallName := 'GetSellingManagerSoldListingsRequest';
sSiteID := '15';
sVersion := '945';
sSaleNo := '2000';
sXML := '<?xml version="1.0"?>'
+ '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'
+ '  xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
+ '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
+ '  <SOAP-ENV:Header>'
+ '    <NS1:RequesterCredentials xmlns:NS1="urn:ebay:apis:eBLBaseComponents">'
+ '      <eBayAuthToken xmlns="urn:ebay:apis:eBLBaseComponents">' + sToken + '</eBayAuthToken>'
+ '      <NS1:Credentials>'
+ '        <AppId xmlns="urn:ebay:apis:eBLBaseComponents">' + sAppID + '</AppId>'
+ '        <DevId xmlns="urn:ebay:apis:eBLBaseComponents">' + sDevID + '</DevId>'
+ '        <AuthCert xmlns="urn:ebay:apis:eBLBaseComponents">' + sCertID + '</AuthCert>'
+ '      </NS1:Credentials>'
+ '    </NS1:RequesterCredentials>'
+ '  </SOAP-ENV:Header>'
+ '  <SOAP-ENV:Body>'
+ '    <GetSellingManagerSoldListingsRequest xmlns="urn:ebay:apis:eBLBaseComponents">'
+ '      <Archived>false</Archived>'
+ '      <DetailLevel>ReturnAll</DetailLevel>'
+ '      <Filter>PaidNotShipped</Filter>'
+ '      <ErrorLanguage>en_AU</ErrorLanguage>'
+ '      <Version>' + sVersion + '</Version>'
+ '    </GetSellingManagerSoldListingsRequest>'
+ '  </SOAP-ENV:Body>'
+ '</SOAP-ENV:Envelope>';
objHttpReqResp.URL := 'https://api.sandbox.ebay.com/wsapi'
+ '?callname=' + sCallName
+ '&siteid=' + sSiteID
+ '&appid=' + sAppID
+ '&version=' + sVersion
+ '&routing=default';
sResponseBody := TStringStream.Create();
try
objHttpReqResp.Execute(sXML, sResponseBody);
xDoc := TXMLDocument.Create(nil);
xDoc.LoadFromStream(sResponseBody);
xDoc.SaveToFile('XML_Output.txt');
memHTML.Lines.LoadFromFile('XML_Output.txt');
memHTML.Lines.Add('');
memHTML.Lines.Add(objHttpReqResp.URL);
memHTML.Lines.Add('');
except
memHTML.Lines.Add('Error happened!');
memHTML.Lines.Add('');
end;
sResponseBody.Free;
end;

现在,错误消息更改为:

<faultcode>soapenv:Server.userException</faultcode>
<faultstring>
com.ebay.app.pres.service.hosting.WebServiceDisabledException:
The web service GetSellingManagerSoldListingsRequest is not properly
configured or not found and is disabled.
</faultstring>

参考faltstring,它显示"未正确配置"。我阅读了易趣开发人员文档https://developer.ebay.com/devzone/xml/docs/reference/ebay/GetSellingManagerSoldListings.html#Request.Pagination.EntriesPerPage但仍然不知道如何正确配置它。

您似乎没有仔细阅读EBAY API文档,web服务xxx不正确已配置或未找到,并且已禁用。根据SOAP调用的提供链接。您将CallName设置为:

sCallName := 'GetSellingManagerSoldListingsRequest';

但应该是:

sCallName := 'GetSellingManagerSoldListings';

此外,我认为与其尝试。。。除了你应该使用try。。。最后阻塞(或两者都阻塞(。

考虑一下如果在您的通话中出现异常会发生什么:

var
sResponseBody: TStringStream; 
begin
...
sResponseBody := TStringStream.Create();
try
objHttpReqResp.Execute(sXML, sResponseBody);
xDoc := TXMLDocument.Create(nil);
xDoc.LoadFromStream(sResponseBody);
xDoc.SaveToFile('XML_Output.txt');
memHTML.Lines.LoadFromFile('XML_Output.txt');
memHTML.Lines.Add('');
memHTML.Lines.Add(objHttpReqResp.URL);
memHTML.Lines.Add('');
except
memHTML.Lines.Add('Error happened!');
memHTML.Lines.Add('');
end;
sResponseBody.Free;

此行:

sResponseBody.Free;

永远不会执行,导致内存泄漏。。。

我不认为你是"愚蠢的程序员",但人们可以清楚地看到你是一个缺乏经验的人:(

Stack Overflow是术语表,而不是讨论论坛,您应该考虑这一点。我强烈建议你阅读"如何提问"部分,以避免投反对票和"粗鲁"的评论和回答。

请考虑一下,我在这里没有任何攻击性,你可能意识到我花了几天时间只是想帮助你,你最终成功的信息是我能在那里赢得的最好的奖品:(

问候

最新更新