delphiebay-api

soapenv:Server.userException -> error from eBay Trading API GetSellingManagerSoldListingsRequest


Thanks for Vancalar's advice and XML codes (refer to: eBay Trading API - calling structure in Delphi), I made a test programs as below:

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;

Returned result is:

<?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>

Does it mean that:

  1. User information has mistake (Token/AppID/DevID/CertID)?
  2. or My code has issue which mixed some parameters?

Any advice? sToken is Seller's eBay token and it is just applied from Developer.ebay.com.

Thanks.

#

Program is updated as below:

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;

Now the error message is changed as:

<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>

Refer to faltstring and it says "not properly configured". I read eBay Developer Document https://developer.ebay.com/devzone/xml/docs/reference/ebay/GetSellingManagerSoldListings.html#Request.Pagination.EntriesPerPage but still don't know how to get it configured properly.


Solution

  • It seems like You didn't read carefully EBAY API documentation and The web service xxx is not properly configured or not found and is disabled. according to provide links for SOAP calls. You put CallName as :

    sCallName := 'GetSellingManagerSoldListingsRequest';
    

    but it should be:

    sCallName := 'GetSellingManagerSoldListings';
    

    Also i think that instead of try... except You should use try... finally block (or both).

    Consider what happens if exception is raised during Your call:

     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;
    

    this line:

     sResponseBody.Free;
    

    would never be executed, leading to memory leak...