Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4d7562b5e04cd6a9d3fed96dddd7679902040c25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 * Copyright (c) 2002, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.ws.internal.explorer.platform.wsdl.actions;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLConnection;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.MessageQueue;
import org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective;
import org.eclipse.wst.ws.internal.parser.discovery.NetUtils;

public class InvokeWSDLHttpPostOperationFormAction extends InvokeWSDLHttpOperationFormAction
{

  public InvokeWSDLHttpPostOperationFormAction(Controller controller)
  {
    super(controller);
  }

  public boolean run()
  {
    WSDLPerspective wsdlPerspective = controller_.getWSDLPerspective();
    MessageQueue messageQueue = wsdlPerspective.getMessageQueue();
    boolean result = false;
    String endPointString = getEndPoint();
    URLConnection conn = NetUtils.getURLConnection(endPointString);
    if (conn != null)
    {
      StringBuffer parameters = new StringBuffer();
      addParameters(parameters);
      conn.setDoOutput(true);
      PrintWriter out = null;
      try
      {
        out = new PrintWriter(conn.getOutputStream());
        out.print(parameters);
        out.close();
        out = null;
        recordHttpResponse(conn,messageQueue);
        wsdlPerspective.setOperationNode(getSelectedNavigatorNode());
        result = true;
      }
      catch (IOException e)
      {
        handleUnexpectedException(wsdlPerspective,messageQueue,"IOException",e);
      }
      finally
      {
        if (out != null)
          out.close();
      }
    }
    else
      handleUnexpectedException(wsdlPerspective,messageQueue,"Exception",new IOException(wsdlPerspective.getMessage("MSG_ERROR_UNABLE_TO_CONNECT",endPointString)));
    return result;
  }
}

Back to the top