}
public W3CEndpointReference createW3CEndpointReference(String address, QName interfaceName, QName serviceName, QName portName,
List<Element> metadata, String wsdlDocumentLocation, List<Element> referenceParameters,
List<Element> elements, Map<QName, String> attributes) {
Container container = ContainerResolver.getInstance().getContainer();
if (address == null) {
if (serviceName == null || portName == null) {
throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS_SERVICE_ENDPOINT());
} else {
//check if it is run in a Java EE Container and if so, get address using serviceName and portName
Module module = container.getSPI(Module.class);
if (module != null) {
List<BoundEndpoint> beList = module.getBoundEndpoints();
for (BoundEndpoint be : beList) {
WSEndpoint wse = be.getEndpoint();
if (wse.getServiceName().equals(serviceName) && wse.getPortName().equals(portName)) {