如何使用 netbeans 和 glassfish 将 http 标头添加到肥皂网络服务?
我的网络服务类:
package com.service;
import com.model.Contact;
import com.model.Phonebook;
import java.util.ArrayList;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "PhonebookService")
public class PhonebookService {
private Phonebook phonebook = new Phonebook();
@WebMethod(operationName = "insert")
public String insert(@WebParam(name = "contact") Contact contact) {
phonebook.add(contact);
return contact.getName() + " inserted";
}
@WebMethod(operationName = "update")
public String update(@WebParam(name = "contact") Contact contact) {
phonebook.update(contact);
return contact.getName() + " updated";
}
@WebMethod(operationName = "remove")
public String remove(@WebParam(name = "contact") Contact contact) {
phonebook.remove(contact);
return contact.getName() + " removed";
}
@WebMethod(operationName = "list")
public ArrayList<Contact> list() {
return phonebook.list();
}
}
我想添加“Access-Control-Allow-Origin:*”标题
我该怎么做?