Package org.apache.soap.transport.http

Examples of org.apache.soap.transport.http.SOAPHTTPConnection


        if (serviceURL == null)
            serviceURL = DEFAULT_SERVICE_URL;
        URL url = new URL(serviceURL);

        // create the transport and set parameters
        SOAPHTTPConnection st = new SOAPHTTPConnection();
        if (proxyHost != null) {
            st.setProxyHost(proxyHost);
            st.setProxyPort(proxyPort);

            if (proxyUserName != null) {
                st.setProxyUserName(proxyUserName);
                st.setProxyPassword(proxyPassword);
            }
        }

        // build the call.
        Call call = new Call();
        call.setSOAPTransport(st);
        call.setTargetObjectURI("urn:xmethods-Temperature");
        call.setMethodName("getTemp");
        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
        Vector params = new Vector();
        params.addElement(new Parameter("zipcode", String.class,
                                        zipcode, null));
        call.setParams(params);

        // invoke it
        System.err.println("Invoking weather service at: ");
        System.err.println("\t" + serviceURL);
        Response resp;
        try {
            // resp = call.invoke(url, null);

            /**
             * Elaborate work-around. xmethods does not like the "charset"
             * modifier on the Content-Type.
             * The work-around mostly consists of a manual implementation
             * of Call.invoke(), with instead of passing the request envelope
             * to the SOAPTransport, manually marshalling it and setting the
             * result as the root part of the request SOAPContext, with a
             * provided Content-Type "text/xml" instead of the default
             * "text/xml; charset=utf-8".
             */
            SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
            SOAPContext reqCtx = call.getSOAPContext();
            DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();

            Envelope callEnv = call.buildEnvelope();
            StringWriter payloadSW = new StringWriter();
            callEnv.marshall(payloadSW, smr, reqCtx);
            reqCtx.setRootPart(payloadSW.toString(),
                               Constants.HEADERVAL_CONTENT_TYPE);

            st.send(url, "", null, null, smr, reqCtx);

            SOAPContext respCtx = st.getResponseSOAPContext();
            String payloadStr = Call.getEnvelopeString(st);
            Document respDoc =
              xdb.parse(new InputSource(new StringReader(payloadStr)));
            Element payload = null;
            if (respDoc != null)
View Full Code Here


        if (serviceURL == null)
            serviceURL = DEFAULT_SERVICE_URL;
        URL url = new URL(serviceURL);

        // create the transport and set parameters
        SOAPHTTPConnection st = new SOAPHTTPConnection();
        if (proxyHost != null) {
            st.setProxyHost(proxyHost);
            st.setProxyPort(proxyPort);
        }

        // build the call.
        Call call = new Call();
        call.setSOAPTransport(st);
        call.setTargetObjectURI("urn:lemurlabs-Fortune");
        if (getList)
            call.setMethodName("getDictionaryNameList");
        else if (dictionary != null) {
            call.setMethodName("getFortuneByDictionary");
            Vector params = new Vector();
            params.addElement(new Parameter("dictionary", String.class,
                                            dictionary, null));
            call.setParams(params);
        } else
            call.setMethodName("getAnyFortune");
        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

        // invoke it
        System.err.println("Invoking fortune service at: ");
        System.err.println("\t" + serviceURL);
        Response resp;
        try {
            // resp = call.invoke(url, null);

            /**
             * Elaborate work-around. lemurlabs does not like the "charset"
             * modifier on the Content-Type.
             * The work-around mostly consists of a manual implementation
             * of Call.invoke(), with instead of passing the request envelope
             * to the SOAPTransport, manually marshalling it and setting the
             * result as the root part of the request SOAPContext, with a
             * provided Content-Type "text/xml" instead of the default
             * "text/xml; charset=utf-8".
             */
            SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
            SOAPContext reqCtx = call.getSOAPContext();
            DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();

            Envelope callEnv = call.buildEnvelope();
            StringWriter payloadSW = new StringWriter();
            callEnv.marshall(payloadSW, smr, reqCtx);
            reqCtx.setRootPart(payloadSW.toString(),
                               Constants.HEADERVAL_CONTENT_TYPE);

            st.send(url, "", null, null, smr, reqCtx);

            SOAPContext respCtx = st.getResponseSOAPContext();
            String payloadStr = Call.getEnvelopeString(st);
            Document respDoc =
              xdb.parse(new InputSource(new StringReader(payloadStr)));
            Element payload = null;
            if (respDoc != null)
View Full Code Here

        throw new SOAPException("Could not create document", null);
      Envelope msgEnv = Envelope.unmarshall(rdoc);
      // create a new message
      Message msg = new Message();
      result.sampleStart();
      SOAPHTTPConnection spconn = null;
      // if a blank HeaderManager exists, try to
      // get the SOAPHTTPConnection. After the first
      // request, there should be a connection object
      // stored with the cookie header info.
      if (this.getHeaderManager() != null && this.getHeaderManager().getSOAPHeader() != null) {
        spconn = (SOAPHTTPConnection) this.getHeaderManager().getSOAPHeader();
      } else {
        spconn = new SOAPHTTPConnection();
      }
           
            spconn.setTimeout(getTimeoutAsInt());
           
      // set the auth. thanks to KiYun Roe for contributing the patch
      // I cleaned up the patch slightly. 5-26-05
      if (getAuthManager() != null) {
        if (getAuthManager().getAuthForURL(getUrl()) != null) {
          AuthManager authmanager = getAuthManager();
          Authorization auth = authmanager.getAuthForURL(getUrl());
          spconn.setUserName(auth.getUser());
          spconn.setPassword(auth.getPass());
        } else {
          log.warn("the URL for the auth was null." + " Username and password not set");
        }
      }
      // check the proxy
      String phost = "";
      int pport = 0;
      // if use proxy is set, we try to pick up the
      // proxy host and port from either the text
      // fields or from JMeterUtil if they were passed
      // from command line
      if (this.getUseProxy()) {
        if (this.getProxyHost().length() > 0 && this.getProxyPort() > 0) {
          phost = this.getProxyHost();
          pport = this.getProxyPort();
        } else {
          if (System.getProperty("http.proxyHost") != null || System.getProperty("http.proxyPort") != null) {
            phost = System.getProperty("http.proxyHost");
            pport = Integer.parseInt(System.getProperty("http.proxyPort"));
          }
        }
        // if for some reason the host is blank and the port is
        // zero, the sampler will fail silently
        if (phost.length() > 0 && pport > 0) {
          spconn.setProxyHost(phost);
          spconn.setProxyPort(pport);
          if (PROXY_USER.length()>0 && PROXY_PASS.length()>0){
            spconn.setProxyUserName(PROXY_USER);
            spconn.setProxyPassword(PROXY_PASS);
          }
        }
      }
      // by default we maintain the session.
      spconn.setMaintainSession(true);
      msg.setSOAPTransport(spconn);
      msg.send(this.getUrl(), this.getSoapAction(), msgEnv);

      if (this.getHeaderManager() != null) {
        this.getHeaderManager().setSOAPHeader(spconn);
View Full Code Here

        throw new SOAPException("Could not create document", null);
      Envelope msgEnv = Envelope.unmarshall(rdoc);
      // create a new message
      Message msg = new Message();
      result.sampleStart();
      SOAPHTTPConnection spconn = null;
      // if a blank HeaderManager exists, try to
      // get the SOAPHTTPConnection. After the first
      // request, there should be a connection object
      // stored with the cookie header info.
      if (this.getHeaderManager() != null && this.getHeaderManager().getSOAPHeader() != null) {
        spconn = (SOAPHTTPConnection) this.getHeaderManager().getSOAPHeader();
      } else {
        spconn = new SOAPHTTPConnection();
      }
           
            spconn.setTimeout(getTimeoutAsInt());
           
      // set the auth. thanks to KiYun Roe for contributing the patch
      // I cleaned up the patch slightly. 5-26-05
      if (getAuthManager() != null) {
        if (getAuthManager().getAuthForURL(getUrl()) != null) {
          AuthManager authmanager = getAuthManager();
          Authorization auth = authmanager.getAuthForURL(getUrl());
          spconn.setUserName(auth.getUser());
          spconn.setPassword(auth.getPass());
        } else {
          log.warn("the URL for the auth was null." + " Username and password not set");
        }
      }
      // check the proxy
      String phost = "";
      int pport = 0;
      // if use proxy is set, we try to pick up the
      // proxy host and port from either the text
      // fields or from JMeterUtil if they were passed
      // from command line
      if (this.getUseProxy()) {
        if (this.getProxyHost().length() > 0 && this.getProxyPort() > 0) {
          phost = this.getProxyHost();
          pport = this.getProxyPort();
        } else {
          if (System.getProperty("http.proxyHost") != null || System.getProperty("http.proxyPort") != null) {
            phost = System.getProperty("http.proxyHost");
            pport = Integer.parseInt(System.getProperty("http.proxyPort"));
          }
        }
        // if for some reason the host is blank and the port is
        // zero, the sampler will fail silently
        if (phost.length() > 0 && pport > 0) {
          spconn.setProxyHost(phost);
          spconn.setProxyPort(pport);
          if (PROXY_USER.length()>0 && PROXY_PASS.length()>0){
            spconn.setProxyUserName(PROXY_USER);
            spconn.setProxyPassword(PROXY_PASS);
          }
        }
      }
      // by default we maintain the session.
      spconn.setMaintainSession(true);
      msg.setSOAPTransport(spconn);
      msg.send(this.getUrl(), this.getSoapAction(), msgEnv);

      if (this.getHeaderManager() != null) {
        this.getHeaderManager().setSOAPHeader(spconn);
View Full Code Here

        throw new SOAPException("Could not create document", null);
      Envelope msgEnv = Envelope.unmarshall(rdoc);
      // create a new message
      Message msg = new Message();
      RESULT.sampleStart();
      SOAPHTTPConnection spconn = null;
      // if a blank HeaderManager exists, try to
      // get the SOAPHTTPConnection. After the first
      // request, there should be a connection object
      // stored with the cookie header info.
      if (this.getHeaderManager() != null && this.getHeaderManager().getSOAPHeader() != null) {
        spconn = (SOAPHTTPConnection) this.getHeaderManager().getSOAPHeader();
      } else {
        spconn = new SOAPHTTPConnection();
      }
      // set the auth. thanks to KiYun Roe for contributing the patch
      // I cleaned up the patch slightly. 5-26-05
      if (getAuthManager() != null) {
        if (getAuthManager().getAuthForURL(getUrl()) != null) {
          AuthManager authmanager = getAuthManager();
          Authorization auth = authmanager.getAuthForURL(getUrl());
          spconn.setUserName(auth.getUser());
          spconn.setPassword(auth.getPass());
        } else {
          log.warn("the URL for the auth was null." + " Username and password not set");
        }
      }
      // check the proxy
      String phost = "";
      int pport = 0;
      // if use proxy is set, we try to pick up the
      // proxy host and port from either the text
      // fields or from JMeterUtil if they were passed
      // from command line
      if (this.getUseProxy()) {
        if (this.getProxyHost().length() > 0 && this.getProxyPort() > 0) {
          phost = this.getProxyHost();
          pport = this.getProxyPort();
        } else {
          if (System.getProperty("http.proxyHost") != null || System.getProperty("http.proxyPort") != null) {
            phost = System.getProperty("http.proxyHost");
            pport = Integer.parseInt(System.getProperty("http.proxyPort"));
          }
        }
        // if for some reason the host is blank and the port is
        // zero, the sampler will fail silently
        if (phost.length() > 0 && pport > 0) {
          spconn.setProxyHost(phost);
          spconn.setProxyPort(pport);
        }
      }
      // by default we maintain the session.
      spconn.setMaintainSession(true);
      msg.setSOAPTransport(spconn);
      msg.send(this.getUrl(), this.getSoapAction(), msgEnv);

      if (this.getHeaderManager() != null) {
        this.getHeaderManager().setSOAPHeader(spconn);
View Full Code Here

TOP

Related Classes of org.apache.soap.transport.http.SOAPHTTPConnection

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.