Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Proxy problems - please help

Reply
Thread Tools

Proxy problems - please help

 
 
Keith-Earl
Guest
Posts: n/a
 
      12-10-2003
I wrote a simple web service a year ago that runs on the clean side of our
firewall. It posts to remote Internet server which sends an alpha page to
my pager. Pretty dandy until last week. It broke, my connection was
refused, not by the remote server but by the ISA proxy.

I read every newsgroup and KB article I could find. Most suggested
modifying the machine.config or web.config file which I did. I also tried
to log into the proxy in code. Once I changed the machine.config file I did
get further (see below).

What am I doing wrong? This code worked reliably for a year.

Thanks,

Keith


<WebMethod()> _
Public Function SendPageProxy(ByVal strPagerID As String, ByVal strMsg
As String) As String

Try

'assign the proxy
Dim myProxy As New
WebProxy("http://www-proxy.thedomain.com:8080", True)
myProxy.Credentials = New NetworkCredential("User", "Pass",
"Domain")

strMsg = strMsg.Substring(0, x)

'Build HttpWebRequest, assign to pager web page
Dim lcUrl As String = "http://thedomain.com/target/send150.pl"
Dim wReq As HttpWebRequest = WebRequest.Create(lcUrl)

'Build POST data
Dim strPostData As String = "host=" +
HttpUtility.UrlEncode("192.168.1.5") & "&pagerid=" +
HttpUtility.UrlEncode(strPagerID) & "&msg=" + HttpUtility.UrlEncode(strMsg)
& "&submit.x=" + HttpUtility.UrlEncode("18") & "&submit.y=" +
HttpUtility.UrlEncode("18")
wReq.Method = "POST"
wReq.ContentType = "application/x-www-form-urlencoded"

'Get length of POST data, set in Request
Dim bytePostBuffer As Byte() =
System.Text.Encoding.GetEncoding(1252).GetBytes(st rPostData)
wReq.ContentLength = bytePostBuffer.Length

'Write out the Post data
===>works Dim streamPostData As Stream = wReq.GetRequestStream() '<===
THIS STATEMENT used to BOMB before I changed the machine.config
streamPostData.Write(bytePostBuffer, 0, bytePostBuffer.Length)

streamPostData.Close()

Dim wRes As HttpWebResponse
===>bombs wRes = wReq.GetResponse() '<=== THIS STATEMENT BOMBS

Dim enc As Encoding = System.Text.Encoding.GetEncoding(1252)
Dim srResponseStream As StreamReader = New
StreamReader(wRes.GetResponseStream(), enc)
Dim strHtml As String = srResponseStream.ReadToEnd()

wRes.Close()
srResponseStream.Close()

'if the ResponseStream contains the word "successfully" assume
it was successful
If InStr(strHtml, "successfully", CompareMethod.Text) Then
Return "Successful"
Else
Return strHtml
End If


Catch ex As Exception
Return ex.Message()
Finally

End Try
End Function

machine.config change

<defaultProxy>

<!-- KAR 10-Dec-03 -->
<proxy usesystemdefault="false"
proxyaddress="http://www-proxy.thedomain.com:8080"
bypassonlocal="true" />


 
Reply With Quote
 
 
 
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      12-11-2003
The reason it is failing is probably because your network config changed,
without your knowledge.

To get this to work, I believe you should be attaching the proxy to the
WebRequest, before writing the POST data.

wReq.Proxy= myProxy ;




"Keith-Earl" <css@NO_SPAMConsultWithUs.com> wrote in message
news:(E-Mail Removed)...
> I wrote a simple web service a year ago that runs on the clean side of our
> firewall. It posts to remote Internet server which sends an alpha page

to
> my pager. Pretty dandy until last week. It broke, my connection was
> refused, not by the remote server but by the ISA proxy.
>
> I read every newsgroup and KB article I could find. Most suggested
> modifying the machine.config or web.config file which I did. I also tried
> to log into the proxy in code. Once I changed the machine.config file I

did
> get further (see below).
>
> What am I doing wrong? This code worked reliably for a year.
>
> Thanks,
>
> Keith
>
>
> <WebMethod()> _
> Public Function SendPageProxy(ByVal strPagerID As String, ByVal strMsg
> As String) As String
>
> Try
>
> 'assign the proxy
> Dim myProxy As New
> WebProxy("http://www-proxy.thedomain.com:8080", True)
> myProxy.Credentials = New NetworkCredential("User", "Pass",
> "Domain")
>
> strMsg = strMsg.Substring(0, x)
>
> 'Build HttpWebRequest, assign to pager web page
> Dim lcUrl As String = "http://thedomain.com/target/send150.pl"
> Dim wReq As HttpWebRequest = WebRequest.Create(lcUrl)
>
> 'Build POST data
> Dim strPostData As String = "host=" +
> HttpUtility.UrlEncode("192.168.1.5") & "&pagerid=" +
> HttpUtility.UrlEncode(strPagerID) & "&msg=" +

HttpUtility.UrlEncode(strMsg)
> & "&submit.x=" + HttpUtility.UrlEncode("18") & "&submit.y=" +
> HttpUtility.UrlEncode("18")
> wReq.Method = "POST"
> wReq.ContentType = "application/x-www-form-urlencoded"
>
> 'Get length of POST data, set in Request
> Dim bytePostBuffer As Byte() =
> System.Text.Encoding.GetEncoding(1252).GetBytes(st rPostData)
> wReq.ContentLength = bytePostBuffer.Length
>
> 'Write out the Post data
> ===>works Dim streamPostData As Stream = wReq.GetRequestStream() '<===
> THIS STATEMENT used to BOMB before I changed the machine.config
> streamPostData.Write(bytePostBuffer, 0, bytePostBuffer.Length)
>
> streamPostData.Close()
>
> Dim wRes As HttpWebResponse
> ===>bombs wRes = wReq.GetResponse() '<=== THIS STATEMENT BOMBS
>
> Dim enc As Encoding = System.Text.Encoding.GetEncoding(1252)
> Dim srResponseStream As StreamReader = New
> StreamReader(wRes.GetResponseStream(), enc)
> Dim strHtml As String = srResponseStream.ReadToEnd()
>
> wRes.Close()
> srResponseStream.Close()
>
> 'if the ResponseStream contains the word "successfully" assume
> it was successful
> If InStr(strHtml, "successfully", CompareMethod.Text) Then
> Return "Successful"
> Else
> Return strHtml
> End If
>
>
> Catch ex As Exception
> Return ex.Message()
> Finally
>
> End Try
> End Function
>
> machine.config change
>
> <defaultProxy>
>
> <!-- KAR 10-Dec-03 -->
> <proxy usesystemdefault="false"
> proxyaddress="http://www-proxy.thedomain.com:8080"
> bypassonlocal="true" />
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inbound Proxy and Outbound Proxy chellappa VOIP 0 04-07-2006 10:58 AM
Press Release: Scalable SIP Proxy and RTP Media Proxy for NAT traversal sales@lanscapecorp.com VOIP 1 01-23-2006 06:32 PM
Help to set up tomcat 4.1.27 behind socks proxy to access database outside the proxy vidy5300 Java 0 06-07-2004 02:23 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments