/** @see SoapClientHandler#putAllHttpHeaders(Object, Map) */
 @Override
 public void putAllHttpHeaders(Stub soapClient, Map<String, String> headersMap) {
   @SuppressWarnings("unchecked")
   Hashtable<String, String> headers =
       (Hashtable<String, String>) soapClient._getProperty(HTTPConstants.REQUEST_HEADERS);
   if (headers == null) {
     headers = new Hashtable<String, String>();
   }
   headers.putAll(headersMap);
   soapClient._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
 }
Beispiel #2
0
 public void loadSession(String url, String cookieString) throws Exception {
   if (_service != null) {
     disconnect();
   }
   _locator = new VimServiceLocator();
   _locator.setMaintainSession(true);
   _service = _locator.getVimPort(new URL(url));
   org.apache.axis.client.Stub st = (org.apache.axis.client.Stub) _service;
   st._setProperty(org.apache.axis.transport.http.HTTPConstants.HEADER_COOKIE, cookieString);
   _locator.setMaintainSession(true);
   _sic = _service.retrieveServiceContent(_svcRef);
 }
Beispiel #3
0
  public void init(String urlStr, String cookieString) throws Exception {
    if (_service != null) {
      disconnect();
    }
    _locator = new VimServiceLocator();
    _locator.setMaintainSession(true);
    _service = _locator.getVimPort(new URL(urlStr));
    _sic = _service.retrieveServiceContent(_svcRef);

    org.apache.axis.client.Stub st = (org.apache.axis.client.Stub) _service;
    org.apache.axis.client.Call callObj = st._getCall();
    org.apache.axis.MessageContext msgContext = callObj.getMessageContext();
    msgContext.setProperty(
        org.apache.axis.transport.http.HTTPConstants.HEADER_COOKIE, cookieString);

    _svcState = ConnectionState_Connected;
  }
 /**
  * Returns a SOAP header from the given SOAP client, if it exists.
  *
  * @param soapClient the SOAP client to check for the given header
  * @param headerName the name of the header being looked for
  * @return the header element, if it exists
  */
 @Override
 public Object getHeader(Stub soapClient, String headerName) {
   SOAPHeaderElement[] soapHeaders = soapClient.getHeaders();
   for (SOAPHeaderElement soapHeader : soapHeaders) {
     if (soapHeader.getName().equals(headerName)) {
       return soapHeader;
     }
   }
   return null;
 }
 /** @see SoapClientHandler#setHeader(Object, String, String, Object) */
 @Override
 public void setHeader(Stub soapClient, String namespace, String headerName, Object headerValue) {
   try {
     QName qName = new QName(namespace, headerName);
     SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(qName);
     soapHeaderElement.setObjectValue(headerValue);
     soapHeaderElement.setActor(null);
     soapClient.setHeader(soapHeaderElement);
   } catch (SOAPException e) {
     throw new ServiceException("Could not set header.", e);
   }
 }
  private MarathonWS2Soap_PortType getService()
      throws FileNotFoundException, ServiceException, Exception {

    EngineConfiguration config = getAxisEngine();
    // String monitorServiceUrl =
    // "http://localhost/SvcFasteignaskra_0201/Fasteignaskra.asmx";

    MarathonWS2Locator locator = new MarathonWS2Locator(config);
    locator.setEndpointAddress("MarathonWS2Soap", getServiceUrl());
    MarathonWS2Soap_PortType port = locator.getMarathonWS2Soap();

    Stub stub = (Stub) port;

    stub._setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    stub._setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    stub._setProperty(WSHandlerConstants.USER, getUserName());
    // stub._setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, this.getClass().getName());
    stub._setProperty(WSHandlerConstants.PW_CALLBACK_REF, this);

    return port;
  }
  public Remote getPort(QName portName, Class serviceEndpointInterface) throws ServiceException {
    if (portName == null) {
      return getPort(serviceEndpointInterface);
    }
    String inputPortName = portName.getLocalPart();
    if ("CrjlServiceImplPort".equals(inputPortName)) {
      return getCrjlServiceImplPort();
    }

    Remote _stub = getPort(serviceEndpointInterface);
    ((Stub) _stub).setPortName(portName);
    return _stub;
  }
  /**
   * Invoke a SOAP call.
   *
   * @param soapCall the call to make to a SOAP web service
   * @return information about the SOAP response
   */
  @Override
  public SoapCallReturn invokeSoapCall(SoapCall<Stub> soapCall) {
    Stub stub = soapCall.getSoapClient();
    SoapCallReturn.Builder builder = new SoapCallReturn.Builder();
    synchronized (stub) {
      Object result = null;
      try {
        result = invoke(soapCall);
      } catch (InvocationTargetException e) {
        builder.withException(e.getTargetException());
      } catch (Exception e) {
        builder.withException(e);
      } finally {
        MessageContext messageContext = stub._getCall().getMessageContext();
        try {
          builder.withRequestInfo(
              new RequestInfo.Builder()
                  .withSoapRequestXml(messageContext.getRequestMessage().getSOAPPartAsString())
                  .withMethodName(stub._getCall().getOperationName().getLocalPart())
                  .withServiceName(stub.getPortName().getLocalPart())
                  .withUrl(stub._getCall().getTargetEndpointAddress())
                  .build());
        } catch (AxisFault e) {
          builder.withException(e);
        }
        try {
          builder.withResponseInfo(
              new ResponseInfo.Builder()
                  .withSoapResponseXml(messageContext.getResponseMessage().getSOAPPartAsString())
                  .build());
        } catch (AxisFault e) {
          builder.withException(e);
        }
      }

      return builder.withReturnValue(result).build();
    }
  }
 /**
  * Sets the read timeout of the given SOAP client.
  *
  * @param soapClient the SOAP client to set the read timeout for
  * @param timeout the timeout in milliseconds
  */
 @Override
 public void setRequestTimeout(Stub soapClient, int timeout) {
   soapClient.setTimeout(timeout);
 }
 /**
  * Sets the endpoint address of the given SOAP client.
  *
  * @param soapClient the SOAP client to set the endpoint address for
  * @param endpointAddress the target endpoint address
  */
 @Override
 public void setEndpointAddress(Stub soapClient, String endpointAddress) {
   soapClient._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
 }
 /** @see SoapClientHandlerInterface#getEndpointAddress(Object) */
 @Override
 public String getEndpointAddress(Stub soapClient) {
   return (String) soapClient._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY);
 }
 /**
  * Set whether SOAP requests should use compression.
  *
  * @param soapClient the client to set compression settings for
  * @param compress whether or not to use compression
  */
 @Override
 public void setCompression(Stub soapClient, boolean compress) {
   soapClient._setProperty(HTTPConstants.MC_ACCEPT_GZIP, compress);
   soapClient._setProperty(HTTPConstants.MC_GZIP_REQUEST, compress);
 }
 /**
  * Clears all of the SOAP headers from the given SOAP client.
  *
  * @param soapClient the client to remove the headers from
  */
 @Override
 public void clearHeaders(Stub soapClient) {
   soapClient._setProperty(HTTPConstants.REQUEST_HEADERS, new Hashtable<String, String>());
   soapClient.clearHeaders();
 }