Skip to content

Instantly share code, notes, and snippets.

@nuttt
Created January 5, 2014 16:56
Show Gist options
  • Select an option

  • Save nuttt/8270691 to your computer and use it in GitHub Desktop.

Select an option

Save nuttt/8270691 to your computer and use it in GitHub Desktop.
Dis sys HW1 Server
package org.student.email;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.xml.ws.WebServiceRef;
import org.oorsprong.websamples.CountryInfoService;
/**
*
* @author nuttt
*/
@WebService(serviceName = "StudentEmailWS")
public class StudentEmailWS {
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso.wsdl")
private CountryInfoService service;
/**
* Web service operation
*/
@WebMethod(operationName = "getStudentEmail")
public String getStudentEmail(@WebParam(name = "name") String name, @WebParam(name = "univ") String univ, @WebParam(name = "country") String country) {
String isoCode = countryISOCode(country);
if (isoCode.equals("No country found by that name")) {
return isoCode;
} else {
return name + "@student." + univ + ".ac." + isoCode.toLowerCase();
}
}
private String countryISOCode(java.lang.String sCountryName) {
// Note that the injected javax.xml.ws.Service reference as well as port objects are not thread safe.
// If the calling of port operations may lead to race condition some synchronization is required.
org.oorsprong.websamples.CountryInfoServiceSoapType port = service.getCountryInfoServiceSoap();
return port.countryISOCode(sCountryName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment