473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VC7, Web Service and Proxy server

Hi,

I am consuing a web service in a VC7 application. I included
the web service as a 'web reference' and calling it's method. Now
I want my application to connect to the web service through a proxy
server. Is this possible? if yes, how?

I have searched but only found proxy use through C# (WebProxy class),
nothing about VC++ 7.

any help would be appreciated.

Thanks,

--

-Farooque Khan
http://farooque.150m.com

Nov 17 '05 #1
5 3542
Are you using ATL Server (is your web reference class a derivative of
CSoapSocketClientT<>) ?
If so, then it has a method called SetProxy which takes as arguments the
name of the proxy server and the port

thanks,
bogdan

--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am consuing a web service in a VC7 application. I included
the web service as a 'web reference' and calling it's method. Now
I want my application to connect to the web service through a proxy
server. Is this possible? if yes, how?

I have searched but only found proxy use through C# (WebProxy class),
nothing about VC++ 7.

any help would be appreciated.

Thanks,

--

-Farooque Khan
http://farooque.150m.com


Nov 17 '05 #2
Thanks Bogdan,

Yes I *was* using CSoapSocketClientT derived class for the web reference.
The SetProxy() method of this works fine, but now I have to provide Proxy
Authentication also. I have now derieved my class from CSoapWininetClient
and trying to use the HINTERNET members to provide proxy authentication
information. I am not yet successfull at this. Can you suggest something? Is
my
approach correct?

Thanks,

--

-Farooque Khan
http://farooque.150m.com


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Are you using ATL Server (is your web reference class a derivative of
CSoapSocketClientT<>) ?
If so, then it has a method called SetProxy which takes as arguments the
name of the proxy server and the port

thanks,
bogdan

--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am consuing a web service in a VC7 application. I included
the web service as a 'web reference' and calling it's method. Now
I want my application to connect to the web service through a proxy
server. Is this possible? if yes, how?

I have searched but only found proxy use through C# (WebProxy class),
nothing about VC++ 7.

any help would be appreciated.

Thanks,

--

-Farooque Khan
http://farooque.150m.com



Nov 17 '05 #3
I think CSoapWininetClient does not support proxy authentication.
A suggestion: you could derive your own class from CSoapWininetClient,
override the ConnectToServer method and copy the old code inside atlsoap.h
for CSoapWininetClient::ConnectToServer, with the modifications highlighted
below:

You will also need to declare 2 new CStringT members, m_strProxyUserName and
m_strProxyPassword, and two new methods to set the values

HRESULT ConnectToServer()
{
if (m_hConnection != NULL)
{
return S_OK;
}

m_hInternet = InternetOpen(
ATLSOAPINET_CLIENT,
m_strProxy.GetLength() ? (INTERNET_OPEN_TYPE_PRECONFIG |
INTERNET_OPEN_TYPE_PROXY) : INTERNET_OPEN_TYPE_PRECONFIG,
m_strProxy.GetLength() ? (LPCTSTR) m_strProxy : NULL,
NULL, 0);

if (m_hInternet != NULL)
{
if (m_dwTimeout != 0)
{
InternetSetOption(m_hInternet, INTERNET_OPTION_CONNECT_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
//////////////////////////////////////////////////////// Add these here:
InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_USERNAME,
m_strProxyUserName.GetBuffer(), m_strProxyUserName.GetLength());
InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_PASSWORD,
m_strProxyPassword.GetBuffer(), m_strProxyPassword.GetLength());
//////////////////////////////////////////////////////// End Extra:

}
m_hConnection = InternetConnect(m_hInternet, m_url.GetHostName(),
(INTERNET_PORT) m_url.GetPortNumber(), NULL, NULL,
INTERNET_SERVICE_HTTP, INTERNET_FLAG_NO_UI, NULL);

if (m_hConnection != NULL)
{
return S_OK;
}
}
CloseAll();
return E_FAIL;
}
Hope this helps!
--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in
message news:%2***************@TK2MSFTNGP09.phx.gbl...
Thanks Bogdan,

Yes I *was* using CSoapSocketClientT derived class for the web reference.
The SetProxy() method of this works fine, but now I have to provide Proxy
Authentication also. I have now derieved my class from CSoapWininetClient
and trying to use the HINTERNET members to provide proxy authentication
information. I am not yet successfull at this. Can you suggest something? Is my
approach correct?

Thanks,

--

-Farooque Khan
http://farooque.150m.com


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Are you using ATL Server (is your web reference class a derivative of
CSoapSocketClientT<>) ?
If so, then it has a method called SetProxy which takes as arguments the
name of the proxy server and the port

thanks,
bogdan

--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no

rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote

in
message news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am consuing a web service in a VC7 application. I included
the web service as a 'web reference' and calling it's method. Now
I want my application to connect to the web service through a proxy
server. Is this possible? if yes, how?

I have searched but only found proxy use through C# (WebProxy class),
nothing about VC++ 7.

any help would be appreciated.

Thanks,

--

-Farooque Khan
http://farooque.150m.com




Nov 17 '05 #4
thanks very much, i will try out.

--

-Farooque Khan
http://farooque.150m.com
RawDisk - A free raw disk editor


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
I think CSoapWininetClient does not support proxy authentication.
A suggestion: you could derive your own class from CSoapWininetClient,
override the ConnectToServer method and copy the old code inside atlsoap.h
for CSoapWininetClient::ConnectToServer, with the modifications highlighted below:

You will also need to declare 2 new CStringT members, m_strProxyUserName and m_strProxyPassword, and two new methods to set the values

HRESULT ConnectToServer()
{
if (m_hConnection != NULL)
{
return S_OK;
}

m_hInternet = InternetOpen(
ATLSOAPINET_CLIENT,
m_strProxy.GetLength() ? (INTERNET_OPEN_TYPE_PRECONFIG |
INTERNET_OPEN_TYPE_PROXY) : INTERNET_OPEN_TYPE_PRECONFIG,
m_strProxy.GetLength() ? (LPCTSTR) m_strProxy : NULL,
NULL, 0);

if (m_hInternet != NULL)
{
if (m_dwTimeout != 0)
{
InternetSetOption(m_hInternet, INTERNET_OPTION_CONNECT_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
//////////////////////////////////////////////////////// Add these here: InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_USERNAME,
m_strProxyUserName.GetBuffer(), m_strProxyUserName.GetLength());
InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_PASSWORD,
m_strProxyPassword.GetBuffer(), m_strProxyPassword.GetLength());
//////////////////////////////////////////////////////// End Extra:

}
m_hConnection = InternetConnect(m_hInternet, m_url.GetHostName(),
(INTERNET_PORT) m_url.GetPortNumber(), NULL, NULL,
INTERNET_SERVICE_HTTP, INTERNET_FLAG_NO_UI, NULL);

if (m_hConnection != NULL)
{
return S_OK;
}
}
CloseAll();
return E_FAIL;
}
Hope this helps!
--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl...
Thanks Bogdan,

Yes I *was* using CSoapSocketClientT derived class for the web reference. The SetProxy() method of this works fine, but now I have to provide Proxy Authentication also. I have now derieved my class from CSoapWininetClient and trying to use the HINTERNET members to provide proxy authentication
information. I am not yet successfull at this. Can you suggest something?
Is
my
approach correct?

Thanks,

--

-Farooque Khan
http://farooque.150m.com


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Are you using ATL Server (is your web reference class a derivative of
CSoapSocketClientT<>) ?
If so, then it has a method called SetProxy which takes as arguments the name of the proxy server and the port

thanks,
bogdan

--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no

rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
> Hi,
>
> I am consuing a web service in a VC7 application. I included
> the web service as a 'web reference' and calling it's method. Now
> I want my application to connect to the web service through a proxy
> server. Is this possible? if yes, how?
>
> I have searched but only found proxy use through C# (WebProxy

class), > nothing about VC++ 7.
>
> any help would be appreciated.
>
> Thanks,
>
> --
>
> -Farooque Khan
> http://farooque.150m.com
>
>
>
>
>



Nov 17 '05 #5
Bogdan, thanks,
your solution and a few other tweaks worked for me.

Apart from CSoapWininetClient, I also have to use InternetErrorDlg()
to take care of 407-401 response (after HttpSendRequest()).

It works now.

Regards,
--

-Farooque Khan
http://farooque.150m.com
RawDisk - A free raw disk editor


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
I think CSoapWininetClient does not support proxy authentication.
A suggestion: you could derive your own class from CSoapWininetClient,
override the ConnectToServer method and copy the old code inside atlsoap.h
for CSoapWininetClient::ConnectToServer, with the modifications highlighted below:

You will also need to declare 2 new CStringT members, m_strProxyUserName and m_strProxyPassword, and two new methods to set the values

HRESULT ConnectToServer()
{
if (m_hConnection != NULL)
{
return S_OK;
}

m_hInternet = InternetOpen(
ATLSOAPINET_CLIENT,
m_strProxy.GetLength() ? (INTERNET_OPEN_TYPE_PRECONFIG |
INTERNET_OPEN_TYPE_PROXY) : INTERNET_OPEN_TYPE_PRECONFIG,
m_strProxy.GetLength() ? (LPCTSTR) m_strProxy : NULL,
NULL, 0);

if (m_hInternet != NULL)
{
if (m_dwTimeout != 0)
{
InternetSetOption(m_hInternet, INTERNET_OPTION_CONNECT_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
InternetSetOption(m_hInternet, INTERNET_OPTION_SEND_TIMEOUT,
&m_dwTimeout, sizeof(m_dwTimeout));
//////////////////////////////////////////////////////// Add these here: InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_USERNAME,
m_strProxyUserName.GetBuffer(), m_strProxyUserName.GetLength());
InternetSetOption(m_hInternet, INTERNET_OPTION_PROXY_PASSWORD,
m_strProxyPassword.GetBuffer(), m_strProxyPassword.GetLength());
//////////////////////////////////////////////////////// End Extra:

}
m_hConnection = InternetConnect(m_hInternet, m_url.GetHostName(),
(INTERNET_PORT) m_url.GetPortNumber(), NULL, NULL,
INTERNET_SERVICE_HTTP, INTERNET_FLAG_NO_UI, NULL);

if (m_hConnection != NULL)
{
return S_OK;
}
}
CloseAll();
return E_FAIL;
}
Hope this helps!
--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl...
Thanks Bogdan,

Yes I *was* using CSoapSocketClientT derived class for the web reference. The SetProxy() method of this works fine, but now I have to provide Proxy Authentication also. I have now derieved my class from CSoapWininetClient and trying to use the HINTERNET members to provide proxy authentication
information. I am not yet successfull at this. Can you suggest something?
Is
my
approach correct?

Thanks,

--

-Farooque Khan
http://farooque.150m.com


"Bogdan Crivat [MSFT]" <bo*****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Are you using ATL Server (is your web reference class a derivative of
CSoapSocketClientT<>) ?
If so, then it has a method called SetProxy which takes as arguments the name of the proxy server and the port

thanks,
bogdan

--
--
--
--
This posting is provided "AS IS" with no warranties, and confers no

rights.
Please do not send email directly to this alias. It is for newsgroup
purposes only.

thanks,
bogdan

"Farooque Khan" <fa*******@NoSpamPls-concretioindia-NoSpamPls.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
> Hi,
>
> I am consuing a web service in a VC7 application. I included
> the web service as a 'web reference' and calling it's method. Now
> I want my application to connect to the web service through a proxy
> server. Is this possible? if yes, how?
>
> I have searched but only found proxy use through C# (WebProxy

class), > nothing about VC++ 7.
>
> any help would be appreciated.
>
> Thanks,
>
> --
>
> -Farooque Khan
> http://farooque.150m.com
>
>
>
>
>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bill Hauver | last post by:
I am attempting to use a web service from my work pc which is behind a firewall. I have used wsdl.exe to create the web service reference class and added it to my project. (this seems to work...
0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
3
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information...
4
by: Steven | last post by:
I have a unmanaged (written in Delphi 6) COM+ Web Service I am accessing through C#.NET. The Web Service takes an string containing a formatted xml read through StreamReader. The problem I am...
3
by: Hans Merkl | last post by:
Hi, I am helping to build a web app that's pretty much a wrapper around a web service. The question now is how to store the handle of the web service object between requests. My client is using...
4
by: Vlad | last post by:
I am implementing class that uses Web service written by another and it is not implemented yet. How can I test my class using NUnit framework without make changes in future when web service will be...
5
by: Nate | last post by:
We are attempting to make a request to a web service (we will refer to it as XXXServices) hosted on a Web Logic server from a C# SOAP client. The server responds with a 401 Unauthorized error...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
2
by: | last post by:
Hi all, I have an asp.net 2.0 website that accesses a locally hosted web service. This works fine on servers that are connected to our network. However, I am having a problem with a laptop...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.