Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-11-2008, 08:20 AM
New Member
 
Posts: 3
Default [SOLVED] [JAVA] SOAP request over http-proxy

Hi,

i'm currently trying to post some soap-requests from our intranet to our server that is in the internet, which means i need to use a proxy. Here's what i try:

Code:
System.setProperty("http.proxySet","true");
System.setProperty("http.proxyHost","http-proxy.my-client.de");
System.setProperty("http.proxyPort","8080"); 

SoapProvisioning sp = new SoapProvisioning();
sp.soapSetURI("https://my-company.de:7071/service/soap");
sp.soapAdminAuthenticate("admin", "adminpwd");

Account account = sp.get(Provisioning.AccountBy.name, "me@my-company.de");
System.out.println(account);
The exception that is thrown shows, that the System-properties regarding the proxy are simply ignored:
[...]
Caused by: java.net.UnknownHostException: my-company.de
[...]

I dont see how i can bind a proxy to the Object of Class SoapProvisioning.

Can anyone help me?

Thanks

Last edited by fink; 12-11-2008 at 08:24 AM..
Reply With Quote
  #2 (permalink)  
Old 12-17-2008, 11:01 AM
Zimbra Employee
 
Posts: 78
Default

SoapProvisioning uses our SoapHttpTransport to invoke the request, which then uses Jakarta Commons HttpClient 3.0. Ideally you should be able to specify SoapTransport options on SoapProvisioning. I poked around in the code and didn't find a way to do this. You could take a look at HttpClient and see if they have their own system-wide properties for specifying a proxy.

If you think this is something we should add to the product, please file an RFE in Bugzilla.
Reply With Quote
  #3 (permalink)  
Old 12-23-2008, 02:07 AM
New Member
 
Posts: 3
Thumbs up Solved

I've checked out the Edison-Branch from your SVN and added a method to SoapProvisioning.java:

Code:
   public void soapSetTransport(HttpClient httpClient, String uri) {
        if (mTransport != null) mTransport.shutdown();
        mTransport = new SoapHttpTransport(httpClient, uri);
        if (mAuthToken != null)
            mTransport.setAuthToken(mAuthToken);
        if (mDebugListener != null)
            mTransport.setDebugListener(mDebugListener);
    }
and a constructor for SoapHttpTransport:

Code:
    public SoapHttpTransport(HttpClient httpClient, String uri)
    {
	super();
	mClient = httpClient;
	commonInit(uri);
     }
Now i can instantiate a SoapProvisioning like this:

Code:
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setProxy("proxy-host", 8080);
SoapProvisioning sp = new SoapProvisioning();
sp.soapSetTransport(httpClient, soapURI);
I've also added a method in ZMailbox.Options:

Code:
        public void setHttpClient(HttpClient httpClient)
        {
        	mHttpClient=httpClient;
        }
and changed the initPreAuth- and setSoapURI-Methods:

Code:
    public void initPreAuth(String uri, SoapTransport.DebugListener listener, HttpClient httpClient) {
        mNameToTag = new HashMap<String, ZTag>();
        mIdToItem = new HashMap<String, ZItem>();                
        setSoapURI(uri, httpClient);
        if (listener != null) mTransport.setDebugListener(listener);
    }

   private void setSoapURI(String uri, HttpClient httpClient) {
        if (mTransport != null) mTransport.shutdown();
        if (httpClient != null)  mTransport = new SoapHttpTransport(httpClient, uri);
        else mTransport = new SoapHttpTransport(uri);
        mTransport.setUserAgent("zclient", BuildInfo.VERSION);
        mTransport.setMaxNoitfySeq(0);
        if (mAuthToken != null)
            mTransport.setAuthToken(mAuthToken);
    }
Now its working
Reply With Quote
  #4 (permalink)  
Old 12-23-2008, 10:06 AM
Zimbra Employee
 
Posts: 78
Default

Great! Glad you were able to get it working. I filed bug 34091 for this issue.
Reply With Quote
  #5 (permalink)  
Old 01-14-2009, 11:30 AM
Zimbra Employee
 
Posts: 78
Default

Oops, I just took a closer look and realized that proxy support was added in 5.0. See bug 15835 for details.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.