Package javax.xml.ws

Examples of javax.xml.ws.WebServiceException


    try {
      return response.get();
    }
    catch (Exception e) {
      throw new WebServiceException(e);
    }
  }
View Full Code Here


    try {
      String urlSpec = (String) _requestContext.get(ENDPOINT_ADDRESS_PROPERTY);

      if (urlSpec == null)
        throw new WebServiceException(L.l("Endpoint address not set"));

      URL url = new URL(urlSpec);
      URLConnection connection = url.openConnection();

      if (response != null)
        connection.setDoInput(true);

      connection.setDoOutput(true);

      // send request
      out = connection.getOutputStream();
     
      OutputStreamWriter writer = null;

      if (_mode == Service.Mode.PAYLOAD) {
        writer = new OutputStreamWriter(out);

        JAXWSUtil.writeStartSOAPEnvelope(writer, _soapNamespace);
      }

      writeRequest(msg, out);

      if (_mode == Service.Mode.PAYLOAD)
        JAXWSUtil.writeEndSOAPEnvelope(writer);

      out.flush();

      // read response
      in = connection.getInputStream();

      // XXX for some reason, it seems this is necessary to force the output
      if (response == null) {
        while (in.read() >= 0) {}

        return;
      }

      ByteArrayOutputStream buffer = new ByteArrayOutputStream();

      if (_mode == Service.Mode.PAYLOAD) {
        JAXWSUtil.extractSOAPBody(in, buffer);
      }
      else {
        // XXX is a copy necessary here or should we expect the client to
        // close the InputStream?
        int ch = -1;

        while ((ch = in.read()) != -1)
          buffer.write(ch);
      }

      response.set(formatResponse(buffer.toByteArray()));
      response.setContext(connection.getHeaderFields());
    }
    catch (WebServiceException e) {
      throw e;
    }
    catch (Exception e) {
      throw new WebServiceException(e);
    }
    finally {
      try {
        if (out != null)
          out.close();

        if (in != null)
          in.close();
      }
      catch (IOException e) {
        throw new WebServiceException(e);
      }
    }
  }
View Full Code Here

        _message = getMessageFactory().createMessage();

      _message.getSOAPPart().setContent(source);
    }
    catch (SOAPException e) {
      throw new WebServiceException(e);
    }
  }
View Full Code Here

     
      if (mode == Service.Mode.PAYLOAD)
        _transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    }
    catch (TransformerConfigurationException e) {
      throw new WebServiceException(e);
    }
  }
View Full Code Here

  {
    try {
      _transformer.transform(msg, new StreamResult(out));
    }
    catch (TransformerException e) {
      throw new WebServiceException(e);
    }
  }
View Full Code Here

      // skip the Envelope
      reader.nextTag();

      if (reader.getEventType() != reader.START_ELEMENT ||
          ! "Envelope".equals(reader.getLocalName())) {
        throw new WebServiceException(L.l("Invalid response from server: No Envelope found"));
      }

      // find the body
      while (reader.hasNext()) {
        reader.next();

        if (reader.getEventType() == reader.START_ELEMENT &&
            "Body".equals(reader.getLocalName())) {

          // Copy the body contents to a StreamDataHandler
          reader.nextTag();

          XMLStreamWriterImpl xmlWriter = new XMLStreamWriterImpl(out, false);

          StaxUtil.copyReaderToWriter(reader, xmlWriter);

          xmlWriter.flush();

          foundBody = true;

          break;
        }
      }
    }
    catch (XMLStreamException e) {
      throw new WebServiceException(e);
    }

    if (! foundBody)
      throw new WebServiceException(L.l("Invalid response from server"));
  }
View Full Code Here

        (HandlerChains) _handlerChainUnmarshaller.unmarshal(is);

      return handlerChains;
    }
    catch (Exception e) {
      throw new WebServiceException(e);
    }
  }
View Full Code Here

      try {
        ClassLoader loader = type.getClassLoader();
        return loader.loadClass(webService.endpointInterface());
      }
      catch (ClassNotFoundException e) {
        throw new WebServiceException(e);
      }
    }

    return type;
  }
View Full Code Here

      dispatch = (Dispatch<T>) new DataSourceDispatch(bindingId, binding,
                                                      mode, _executor);
    }

    if (dispatch == null) {
      throw new WebServiceException(L.l("{0} is an unsupported Dispatch type",
                                        type));
    }

    if (endpointAddress != null) {
      Map<String,Object> requestContext = dispatch.getRequestContext();
View Full Code Here

        try {
            this.endpointInstance = this.holder.newInstance(this.endpointClass.getName(),
                                                            this.endpointClass.getClassLoader(),
                                                            this.context);
        } catch (Exception e) {
            throw new WebServiceException("Service resource injection failed", e);
        }
       
        this.annotationProcessor =
            new JAXWSAnnotationProcessor(this.jndiResolver, new POJOWebServiceContext());

        // configure and inject handlers
        try {
            configureHandlers();
            injectHandlers();
        } catch (Exception e) {
            throw new WebServiceException("Error configuring handlers", e);
        }
       
    }
View Full Code Here

TOP

Related Classes of javax.xml.ws.WebServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.