/** Creates WS-Addressing pipe */
 public Tube createWsaTube(Tube next) {
   if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding)) {
     if (AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
       return new MemberSubmissionWsaServerTube(endpoint, wsdlModel, binding, next);
     } else {
       return new W3CWsaServerTube(endpoint, wsdlModel, binding, next);
     }
   } else return next;
 }
Пример #2
0
  public W3CEndpointReference createW3CEndpointReference(
      String address,
      QName serviceName,
      QName portName,
      List<Element> metadata,
      String wsdlDocumentLocation,
      List<Element> referenceParameters) {
    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)) {
              try {
                address = be.getAddress().toString();
              } catch (WebServiceException e) {
                // May be the container does n't support this
                // just ignore the exception
              }
              break;
            }
          }
        }
        // address is still null? may be its not run in a JavaEE Container
        if (address == null) throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS());
      }
    }
    if ((serviceName == null) && (portName != null)) {
      throw new IllegalStateException(ProviderApiMessages.NULL_SERVICE());
    }
    // Validate Service and Port in WSDL
    if (wsdlDocumentLocation != null) {
      try {
        EntityResolver er = XmlUtil.createDefaultCatalogResolver();

        URL wsdlLoc = new URL(wsdlDocumentLocation);
        WSDLModelImpl wsdlDoc =
            RuntimeWSDLParser.parse(
                wsdlLoc,
                new StreamSource(wsdlLoc.toExternalForm()),
                er,
                false,
                container,
                ServiceFinder.find(WSDLParserExtension.class).toArray());
        if (serviceName != null) {
          WSDLService wsdlService = wsdlDoc.getService(serviceName);
          if (wsdlService == null)
            throw new IllegalStateException(
                ProviderApiMessages.NOTFOUND_SERVICE_IN_WSDL(serviceName, wsdlDocumentLocation));
          if (portName != null) {
            WSDLPort wsdlPort = wsdlService.get(portName);
            if (wsdlPort == null)
              throw new IllegalStateException(
                  ProviderApiMessages.NOTFOUND_PORT_IN_WSDL(
                      portName, serviceName, wsdlDocumentLocation));
          }
        }
      } catch (Exception e) {
        throw new IllegalStateException(ProviderApiMessages.ERROR_WSDL(wsdlDocumentLocation), e);
      }
    }
    // Supress writing ServiceName and EndpointName in W3C EPR,
    // Until the ns for those metadata elements is resolved.
    return new WSEndpointReference(
            AddressingVersion.fromSpecClass(W3CEndpointReference.class),
            address,
            null /*serviceName*/,
            null /*portName*/,
            null,
            metadata,
            null /*wsdlDocumentLocation*/,
            referenceParameters)
        .toSpec(W3CEndpointReference.class);
  }