Skip to main content
Published: September 15 2010, 10:37:00 PMUpdated: November 28 2020, 8:46:08 PM

  How can I generate Java code stubs against ResolutionCaseManagement API WSDL using wsimport tool and make calls?

This sample uses wsimport tool that ships with JAX-WS to generate Java code stubs and demonstrates how to make API calls to the ResolutionCaseManagement service.

Software Requirements:

1. Generate Java code stub using wsimport tool.

wsimport -extension https://svcs.ebay.com/ws/spf?wsdl&X-EBAY-SOA-SERVICE-NAME=ResolutionCaseManagementService

2. Create a jar file with the generated classes.

Run the following command from the same location where the previous command was run

jar -cvf resolutionCMS.jar .

3. Add the jar to the classpath along with jax-ws lib folder.

The follwing sample shows how to call the getEBPCaseDetails/getUserCases call.

4. To log SOAP Requests and response you need to add a Handler to the binding's handler chain. This is commented out int he code. If you need that enabled uncomment the code and impor the logging handler file that is attached.

/*  © 2010-2013 eBay Inc., All Rights Reserved */
/* Licensed under CDDL 1.0 -  http://opensource.org/licenses/cddl1.php */

package 
com.ebay.sample.rcms;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.MessageContext;

import com.ebay.marketplace.resolution.v1.services.CaseArrayType;
import com.ebay.marketplace.resolution.v1.services.CaseIdType;
import com.ebay.marketplace.resolution.v1.services.CaseStatusType;
import com.ebay.marketplace.resolution.v1.services.CaseSummaryType;
import com.ebay.marketplace.resolution.v1.services.CaseType;
import com.ebay.marketplace.resolution.v1.services.ErrorData;
import com.ebay.marketplace.resolution.v1.services.GetEBPCaseDetailRequest;
import com.ebay.marketplace.resolution.v1.services.GetEBPCaseDetailResponse;
import com.ebay.marketplace.resolution.v1.services.GetUserCasesRequest;
import com.ebay.marketplace.resolution.v1.services.GetUserCasesResponse;
import com.ebay.marketplace.resolution.v1.services.ResolutionCaseManagementService;
import com.ebay.marketplace.resolution.v1.services.ResolutionCaseManagementServicePort;

public class ResolutionCaseMgmtTest {

  public static void testEBPCaseDetail(String caseID) {

    ResolutionCaseManagementService service = new ResolutionCaseManagementService();

    ResolutionCaseManagementServicePort port = service
        .getResolutionCaseManagementServiceHttpPort();
    // This is the production URL for Resolution Service
    String strBaseURL = "https://svcs.ebay.com/services/resolution/ResolutionCaseManagementService/v1";

    BindingProvider bp = (BindingProviderport;

    Map<String, Object> requestProperties = bp.getRequestContext();

    Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();

    // Set the headers
    httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL",
        Collections.singletonList("SOAP12"));
    httpHeaders.put("X-EBAY-SOA-SERVICE-NAME",
        Collections.singletonList("ResolutionCaseManagementService"));
    httpHeaders.put("X-EBAY-SOA-OPERATION-NAME",
        Collections.singletonList("getEBPCaseDetail"));
    httpHeaders
        .put("X-EBAY-SOA-SECURITY-TOKEN",
            Collections
                .singletonList("TOKEN"));

    requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
    requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
        strBaseURL);

    // Uncomment the following block of code and import LoggingHandler.java
    // if you need to log your request/response XMLs

    /*Binding bind = bp.getBinding();
    List<Handler> handList = bind.getHandlerChain();
    if (handList == null) {
      handList = new ArrayList<Handler>();
    }
    LoggingHandler logger = new LoggingHandler();
    handList.add(logger);
    bind.setHandlerChain(handList);*/

    GetEBPCaseDetailRequest req = new GetEBPCaseDetailRequest();
    CaseIdType caseId = new CaseIdType();
    caseId.setId(caseID);
    caseId.setType(CaseType.EBP_INR);
    req.setCaseId(caseId);

    try {
      GetEBPCaseDetailResponse response = port.getEBPCaseDetail(req);
      if (response.getAck().value().equalsIgnoreCase("Success")) {
        CaseSummaryType summary = response.getCaseSummary();
        System.out.println("CaseID : " + summary.getCaseId());
        System.out.println("Item ID: " + summary.getItem().getItemId());
        System.out.println("Item Title : "
            + summary.getItem().getItemTitle());
        System.out.println("Status : "
            + summary.getStatus().getEBPINRStatus().value());
      else if (response.getErrorMessage() != null) {
        System.out
            .format("The request failed for the follwing reason(s):\n");
        List<ErrorData> errors = response.getErrorMessage().getError();
        for (ErrorData errorData : errors) {
          System.out.format(
              "Error Serverity: %s \t Error Message: %s",
              errorData.getSeverity().value(),
              errorData.getMessage());
        }
      }
    catch (Exception e) {
      System.out.println("An exception occured during the call : ");
      e.printStackTrace();
    }

  }

  public static void testUserCase() {

    ResolutionCaseManagementService service = new ResolutionCaseManagementService();

    ResolutionCaseManagementServicePort port = service
        .getResolutionCaseManagementServiceHttpPort();
    // This is the production URL for Resolution Service
    String strBaseURL = "https://svcs.ebay.com/services/resolution/ResolutionCaseManagementService/v1";

    BindingProvider bp = (BindingProviderport;

    Map<String, Object> requestProperties = bp.getRequestContext();

    Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();

    // Set the headers
    httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL",
        Collections.singletonList("SOAP12"));
    httpHeaders.put("X-EBAY-SOA-SERVICE-NAME",
        Collections.singletonList("ResolutionCaseManagementService"));
    httpHeaders.put("X-EBAY-SOA-OPERATION-NAME",
        Collections.singletonList("getUserCases"));
    httpHeaders
        .put("X-EBAY-SOA-SECURITY-TOKEN",
            Collections
                .singletonList("TOKEN"));

    requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
    requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
        strBaseURL);

    // Uncomment the following block of code and import LoggingHandler.java
    // if you need to log your request/response XMLs
    
    /*
    Binding bind = bp.getBinding();
    List<Handler> handList = bind.getHandlerChain();
    if (handList == null) {
      handList = new ArrayList<Handler>();
    }
    LoggingHandler logger = new LoggingHandler();
    handList.add(logger);
    bind.setHandlerChain(handList);*/

    try {
      GetUserCasesRequest getUserCases = new GetUserCasesRequest();

      GetUserCasesResponse response = port.getUserCases(getUserCases);

      if (response.getAck().value().equalsIgnoreCase("Success")) {
        CaseArrayType caseArray = response.getCases();
        List<CaseSummaryType> caseList = caseArray.getCaseSummary();
        for (CaseSummaryType summary : caseList) {
          CaseIdType caseID = summary.getCaseId();
          System.out.println("CaseID : " + caseID.getId());
          System.out.println("CaseID : " + caseID.getType().name());
          System.out.println("Item ID: "
              + summary.getItem().getItemId());
          System.out.println("Item Title : "
              + summary.getItem().getItemTitle());
          CaseStatusType status = summary.getStatus();
          switch (caseID.getType()) {
          case CANCEL_TRANSACTION:
            System.out
                .println("The Transaction's cancel status is : "
                    + summary.getStatus()
                        .getCancelTransactionStatus());
            break;
          case EBP_INR:
            System.out.println("The Transaction's INR status is : "
                + status.getEBPINRStatus());
            break;
          case UPI:
            System.out.println("The Transaction's UPI status is : "
                + status.getUPIStatus());
            break;
          case RETURN:
            System.out.println("The Transaction's Return status is : "
                + status.getReturnStatus());
            break;
          // More case: here
          }
          System.out.println();
        }
      else if (response.getErrorMessage() != null) {
        System.out
            .format("The request failed for the follwing reason(s):\n");
        List<ErrorData> errors = response.getErrorMessage().getError();
        for (ErrorData errorData : errors) {
          System.out.format(
              "Error Serverity: %s \t Error Message: %s",
              errorData.getSeverity().value(),
              errorData.getMessage());
        }
      }
    catch (Exception e) {
      System.out.println("An exception occured during the call : ");
      e.printStackTrace();
    }

  }

  public static void main(String[] args) {
    testEBPCaseDetail("500498766");
    testUserCase();
  }

}

We've attached the sample code and the generated jar to this. But please note that this is only for reference. Its always advisable to generate the classes from the latest WSDL.

How well did this answer your question?
Answers others found helpful