コード例 #1
0
  protected void addMessageFromBinding(
      ExtensibilityElement ext, BindingOperationInfo bop, boolean isInput) {
    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);

    ServiceInfo serviceInfo = bop.getBinding().getService();

    if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
      Definition def = (Definition) serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
      SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();

      if (def != null && schemas != null) {
        QName qn = header.getMessage();

        javax.wsdl.Message msg = findMessage(qn, def);
        if (msg != null) {
          addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
          serviceInfo.refresh();
        } else {
          throw new RuntimeException(
              "Problem with WSDL: soap:header element"
                  + " for operation "
                  + bop.getName()
                  + " is referring to an undefined wsdl:message element: "
                  + qn);
        }
      }
    }
  }
コード例 #2
0
ファイル: JAXBDataBinding.java プロジェクト: Jutten/cxf
 private void justCheckForJAXBAnnotations(ServiceInfo serviceInfo) {
   for (MessageInfo mi : serviceInfo.getMessages().values()) {
     for (MessagePartInfo mpi : mi.getMessageParts()) {
       checkForJAXBAnnotations(
           mpi, serviceInfo.getXmlSchemaCollection(), serviceInfo.getTargetNamespace());
     }
   }
 }
コード例 #3
0
 private static ServiceInfo findServiceByName(
     org.apache.cxf.service.Service cxfService, QName serviceName) {
   for (ServiceInfo si : cxfService.getServiceInfos()) {
     if (si.getName().equals(serviceName)) {
       return si;
     }
   }
   return null;
 }
コード例 #4
0
  public void initialize(Service service) {
    if (LOG.isLoggable(Level.FINER)) {
      LOG.log(Level.FINER, "Creating XmlBeansDatabinding for " + service.getName());
    }
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
      SchemaCollection col = serviceInfo.getXmlSchemaCollection();

      if (col.getXmlSchemas().length > 1) {
        // someone has already filled in the types
        continue;
      }

      XmlBeansSchemaInitializer schemaInit = new XmlBeansSchemaInitializer(serviceInfo, col, this);
      schemaInit.walk();
    }
  }
コード例 #5
0
 private static EndpointInfo findEndpoint(ServiceInfo si, QName name) {
   for (EndpointInfo ei : si.getEndpoints()) {
     if (name.equals(ei.getName())) {
       return ei;
     }
   }
   return null;
 }
コード例 #6
0
  public void loadJavascriptForService(ServiceInfo serviceInfo) {
    Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
    BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixManager =
        new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
      SchemaJavascriptBuilder builder =
          new SchemaJavascriptBuilder(
              serviceInfo.getXmlSchemaCollection(), prefixManager, nameManager);
      String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
      readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
    }

    ServiceJavascriptBuilder serviceBuilder =
        new ServiceJavascriptBuilder(serviceInfo, null, prefixManager, nameManager);
    serviceBuilder.walk();
    String serviceJavascript = serviceBuilder.getCode();
    readStringIntoRhino(serviceJavascript, serviceInfo.getName() + ".js");
  }
コード例 #7
0
ファイル: ServiceModelVisitor.java プロジェクト: CMoH/cxf
  public void walk() {
    begin(serviceInfo);
    begin(serviceInfo.getInterface());

    for (OperationInfo o : serviceInfo.getInterface().getOperations()) {
      begin(o);

      visitOperation(o);

      end(o);
    }

    end(serviceInfo.getInterface());
    for (EndpointInfo endpointInfo : serviceInfo.getEndpoints()) {
      begin(endpointInfo);
      end(endpointInfo);
    }
    for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
      begin(bindingInfo);
      end(bindingInfo);
    }
    end(serviceInfo);
  }
コード例 #8
0
  public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
    SoapBindingConfiguration config;
    if (conf instanceof SoapBindingConfiguration) {
      config = (SoapBindingConfiguration) conf;
    } else {
      config = new SoapBindingConfiguration();
    }
    if (WSDLConstants.NS_SOAP12.equals(bindingid)
        || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
      config.setVersion(Soap12.getInstance());
      config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());

    info.setName(config.getBindingName(si));
    info.setStyle(config.getStyle());

    info.setTransportURI(config.getTransportURI());

    if (config.isMtomEnabled()) {
      info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
    }

    for (OperationInfo op : si.getInterface().getOperations()) {
      SoapOperationInfo sop = new SoapOperationInfo();
      sop.setAction(config.getSoapAction(op));
      sop.setStyle(config.getStyle(op));

      BindingOperationInfo bop =
          info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());

      bop.addExtensor(sop);

      info.addOperation(bop);

      BindingMessageInfo bInput = bop.getInput();
      if (bInput != null) {
        MessageInfo input = null;
        BindingMessageInfo unwrappedMsg = bInput;
        if (bop.isUnwrappedCapable()) {
          input = bop.getOperationInfo().getUnwrappedOperation().getInput();
          unwrappedMsg = bop.getUnwrappedOperation().getInput();
        } else {
          input = bop.getOperationInfo().getInput();
        }
        setupHeaders(bop, bInput, unwrappedMsg, input, config);
      }

      BindingMessageInfo bOutput = bop.getOutput();
      if (bOutput != null) {
        MessageInfo output = null;
        BindingMessageInfo unwrappedMsg = bOutput;
        if (bop.isUnwrappedCapable()) {
          output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
          unwrappedMsg = bop.getUnwrappedOperation().getOutput();
        } else {
          output = bop.getOperationInfo().getOutput();
        }
        setupHeaders(bop, bOutput, unwrappedMsg, output, config);
      }
    }

    try {
      createSoapBinding(info);
    } catch (WSDLException e) {
      e.printStackTrace();
    }

    return info;
  }
コード例 #9
0
ファイル: JAXBDataBinding.java プロジェクト: Jutten/cxf
  @SuppressWarnings("unchecked")
  public synchronized void initialize(Service service) {

    inInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
    inFaultInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);

    // context is already set, don't redo it
    if (context != null) {
      return;
    }

    contextClasses = new LinkedHashSet<Class<?>>();
    Map<String, Object> unmarshallerProps = new HashMap<String, Object>();
    this.setUnmarshallerProperties(unmarshallerProps);
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {

      JAXBContextInitializer initializer =
          new JAXBContextInitializer(
              serviceInfo, contextClasses, typeRefs, this.getUnmarshallerProperties());
      initializer.walk();
      if (serviceInfo.getProperty("extra.class") != null) {
        Set<Class<?>> exClasses = serviceInfo.getProperty("extra.class", Set.class);
        contextClasses.addAll(exClasses);
      }
    }

    String tns = getNamespaceToUse(service);
    CachedContextAndSchemas cachedContextAndSchemas = null;
    JAXBContext ctx = null;
    try {
      cachedContextAndSchemas = createJAXBContextAndSchemas(contextClasses, tns);
    } catch (JAXBException e1) {
      throw new ServiceConstructionException(e1);
    }
    ctx = cachedContextAndSchemas.getContext();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.log(Level.FINE, "CREATED_JAXB_CONTEXT", new Object[] {ctx, contextClasses});
    }
    setContext(ctx);

    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
      SchemaCollection col = serviceInfo.getXmlSchemaCollection();

      if (col.getXmlSchemas().length > 1) {
        // someone has already filled in the types
        justCheckForJAXBAnnotations(serviceInfo);
        continue;
      }

      boolean schemasFromCache = false;
      Collection<DOMSource> schemas = getSchemas();
      if (schemas == null || schemas.size() == 0) {
        schemas = cachedContextAndSchemas.getSchemas();
        if (schemas != null) {
          schemasFromCache = true;
        }
      } else {
        schemasFromCache = true;
      }
      Set<DOMSource> bi = new LinkedHashSet<DOMSource>();
      if (schemas == null) {
        schemas = new LinkedHashSet<DOMSource>();
        try {
          for (DOMResult r : generateJaxbSchemas()) {
            DOMSource src = new DOMSource(r.getNode(), r.getSystemId());
            if (BUILT_IN_SCHEMAS.containsValue(r)) {
              bi.add(src);
            } else {
              schemas.add(src);
            }
          }
          // put any builtins at the end.   Anything that DOES import them
          // will cause it to load automatically and we'll skip them later
          schemas.addAll(bi);
        } catch (IOException e) {
          throw new ServiceConstructionException("SCHEMA_GEN_EXC", LOG, e);
        }
      }
      Set<String> ids = new HashSet<String>();
      for (DOMSource r : schemas) {
        ids.add(r.getSystemId());
      }
      for (DOMSource r : schemas) {
        if (bi.contains(r)) {
          String ns = ((Document) r.getNode()).getDocumentElement().getAttribute("targetNamespace");
          if (serviceInfo.getSchema(ns) != null) {
            continue;
          }
        }
        // StaxUtils.print(r.getNode());
        // System.out.println();
        addSchemaDocument(serviceInfo, col, (Document) r.getNode(), r.getSystemId());
      }

      JAXBSchemaInitializer schemaInit =
          new JAXBSchemaInitializer(serviceInfo, col, context, this.qualifiedSchemas, tns);
      schemaInit.walk();
      if (cachedContextAndSchemas != null && !schemasFromCache) {
        cachedContextAndSchemas.setSchemas(schemas);
      }
    }
  }