code sample icon Sample Code

In the generated service implementation Java file, replace the code:

                               
public void processRating(@WebParam(name = "CreditRatingDetailsElement", 
                          partName = "part", 
                          targetNamespace = "http://www.example.org", 
                          mode = WebParam.Mode.INOUT)
  Holder<CreditRatingDetails> part) {
}
                            

With the following sample code:

                               
public void processRating(@WebParam(name = "CreditRatingDetailsElement", 
                          partName = "part", 
                          targetNamespace = "http://www.example.org", 
                          mode = WebParam.Mode.INOUT)
  Holder<CreditRatingDetails> part) {
  int id = 0;
  try {
      // Parses integer value of first 3 numbers form SSN 
      id = Integer.parseInt(part.value.getSsn().substring(0, 3));
  } catch (NumberFormatException e) {
      // if SSN is invalid returns -1 
      part.value.setRating(-1);
      return;
  }
  if (id < 300) {
      // If value of the first 3 numbers from customer SSN is less 
      // than 300, rating is 1. 
      part.value.setRating(1);
  } else if (id < 600) {
      // If value less than 600, rating is 2. 
      part.value.setRating(2);
  } else if (id < 900) {
      // If value less than 900, rating is 3. 
      part.value.setRating(3);
  } else {
      // Otherwise, rating is 0. 
      part.value.setRating(0);
  }
  return;
}
                            

Instead of typing the sample code, you can copy the code in this window and then paste it into the source editor.

Copyright © 1997, 2009, Oracle. All rights reserved.

false ,,,,,,,,,,,,,,,