WebService Cant Send soap thru proxy
<p>I'm very new to webservice request and response. I did search how to connect webservices to proxys like this post: <a href="https://stackoverflow.com/questions/13933048/webservice-with-https">Webservice with HTTPS</a> and also several other post in this forum. I failed to connect to the webservice through the proxy.</p>

<p>Here is my code:</p>

<pre><code>final String WS_URL_HTTP = "https://bcrmpiqci.tnb.com.my/dir/wsdl?p=ic/653b15a2bf3e3bfda703456d4ceac77e";

final String endPoint = "https://bcrmpiqci.hq.tnb.com.my:50101/XISOAPAdapter/MessageServlet?senderParty=&amp;senderService=INFINITIUM&amp;receiverParty=&amp;receiverService=&amp;interface=AutoPayRegistrationRequestAsync_Out&amp;interfaceNamespace=urn:tnb.com.my:BCRM:po:PROC:FICA:AutoPay:1.0";

final String username = "username";
final String password = "password";


HttpsURLConnection con = null;

        try {
            URL url = new URL(WS_URL_HTTP);

            //binding the authenticator 
            Authenticator.setDefault(new Authenticator() {

                @Override
                protected PasswordAuthentication getPasswordAuthentication() {          
                    return new PasswordAuthentication(username, password.toCharArray());
                }
            });


            //con = (HttpURLConnection) url.openConnection();
            con = (HttpsURLConnection) url.openConnection();

            int resp = con.getResponseCode();



            if(resp == 200){

                AutoPayRegistrationRequestAsyncOutService service = new    AutoPayRegistrationRequestAsyncOutService();

                System.out.println(service.getHTTPSPort());



                BindingProvider bindingProvider = (BindingProvider) service;
                bindingProvider.getRequestContext()
                    .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);

                System.out.println(resp + " connection return ok! ");
                System.out.println(con.getHeaderFields()); 

                //put the payload soap envelop here 

                Header header = new Header();
                header.setFileName("ujabbbbbbb");
                header.setItemCount("3");
                header.setSystemName("TNBEBPP");
                header.setMessageID("98");
                header.setPaymentID("300");
                header.setSystemPassword("p@ssw0rd");


                Item item = new Item();
                item.setContractAccountNumber("880909090");
                item.setItemMessageID("00");
                item.setNewCreditCardNumber("4111111111111111");
                item.setNewTokenID("adasdoqwiejijadsol");
                item.setOldCreditCardNumber("4111111111111114");
                item.setRegistrationIndicator("55");
                item.setSenderSystemIndicator("00");


                AutoPayRegistrationAsyncRequest.AutoPayRegistration value = new AutoPayRegistrationAsyncRequest.AutoPayRegistration();
                value.setHeader(header);
                value.getItem().add(item);


                AutoPayRegistrationAsyncRequest req = new AutoPayRegistrationAsyncRequest();
                req.setAutoPayRegistration(value);


                AutoPayRegistrationRequestAsyncOut out = service.getHTTPSPort();
                out.autoPayRegistrationRequestAsyncOut(req);

                System.out.println(out.toString());
    } else {

                System.out.println(resp);
                System.out.println("error authenticate or malform url");

            }




        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {

            con.disconnect();

        }
</code></pre>

<p>I hope you guys can enlighten my knowledge here. </p>

<p>My wsdl:</p>

<pre><code>&lt;wsdl:port name="HTTPS_Port" binding="p1:AutoPayRegistrationRequestAsync_OutBinding"&gt;
&lt;soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="https://bcrmpiqci.hq.tnb.com.my:50101/XISOAPAdapter/MessageServlet?senderParty=&amp;senderService=INFINITIUM&amp;receiverParty=&amp;receiverService=&amp;interface=AutoPayRegistrationRequestAsync_Out&amp;interfaceNamespace=urn%3Atnb.com.my%3ABCRM%3Apo%3APROC%3AFICA%3AAutoPay%3A1.0"/&gt;
&lt;/wsdl:port&gt;
</code></pre>