package tr.hba.springws.model;
public class Campaign {
private String name;
private String code;
private String content;
public Campaign(String name, String content){
this.name = name;
this.content = content;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the content
*/
public String getContent() {
return content;
}
/**
* @param content the content to set
*/
public void setContent(String content) {
this.content = content;
}
}
şimdi de webservis class larımızı oluşturalım.
package tr.hba.springws;
import java.util.List;
import javax.jws.WebParam;
import javax.jws.WebService;
import tr.hba.springws.model.Campaign;
@WebService
public interface CampaignWS {
String campaignAdd(@WebParam(name = "campaign") Campaign campaign);
List campaignList();
}
package tr.hba.springws;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
import tr.hba.springws.model.Campaign;
@WebService(endpointInterface = "tr.hba.springws.CampaignWS")
public class CampaignWSImpl implements CampaignWS{
public String campaignAdd(Campaign campaign) {
System.out.println(campaign.getName());
return "OK";
}
public List campaignList() {
List campaignList = new ArrayList();
Campaign campaign1 = new Campaign("name 1","content 1");
Campaign campaign2 = new Campaign("name 2","content 2");
Campaign campaign3 = new Campaign("name 3","content 3");
Campaign campaign4 = new Campaign("name 4","content 4");
Campaign campaign5 = new Campaign("name 5","content 5");
campaignList.add(campaign1);
campaignList.add(campaign2);
campaignList.add(campaign3);
campaignList.add(campaign4);
campaignList.add(campaign5);
return campaignList;
}
}
applicationContext.xml ayarları
ve son olarak web.xml
SpringWS
contextConfigLocation
classpath:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
CXFServlet
org.apache.cxf.transport.servlet.CXFServlet
CXFServlet
/webservices/*
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
sonuç
http://localhost:8080/SpringWS/webservices/
http://localhost:8080/SpringWS/webservices/campaignWS?wsdl
Hiç yorum yok:
Yorum Gönder