I created a desktop application (vb.net) which access my webservice. I have a
client which is behind a firewall and can not log on to the webservice. They
have been getting the error: System.Net.WebE xception: The request failed with
HTTP status 403: Forbidden.
Any ideas on what I can do. Here is my code.
Dim myService As New AIMWS.DataServ1 Wse
Dim proxyObject As New System.Net.WebP roxy(m_strURLLo cation, True)
myService.Proxy = proxyObject
myService.Ping( )
<System.Web.Ser vices.Protocols .SoapDocumentMe thodAttribute(W ebServiceAddres s
& "/Ping", RequestNamespac e:=WebServiceAd dress,
ResponseNamespa ce:=WebServiceA ddress,
Use:=System.Web .Services.Descr iption.SoapBind ingUse.Literal,
ParameterStyle: =System.Web.Ser vices.Protocols .SoapParameterS tyle.Wrapped)> _
Public Function Ping() As Integer
Dim results() As Object = Me.Invoke("Ping ", New Object(-1) {})
Return CType(results(0 ),Integer)
End Function
<WebMethod()> Public Function Ping() As Integer
If Authenticater() Then
' Just make sure that Ping works, to see if the web service is
valid
End If
End Function
Private Function Authenticater() As Boolean
Dim requestContext As SoapContext = HttpSoapContext .RequestContext
Dim userToken As UsernameToken
Dim returnValue As String
If requestContext Is Nothing Then
Throw New SoapException(" Non-SOAP Message - Are you a hacker?",
SoapException.C lientFaultCode)
End If
For Each userToken In requestContext. Security.Tokens
If TypeOf userToken Is UsernameToken Then
If userToken.Passw ordOption = PasswordOption. SendHashed Then
Return True
Exit For
Else
Throw New SoapException(" Password must be hashed",
SoapException.C lientFaultCode)
End If
End If
Next
End Function
--
Thanks,
JeffS
client which is behind a firewall and can not log on to the webservice. They
have been getting the error: System.Net.WebE xception: The request failed with
HTTP status 403: Forbidden.
Any ideas on what I can do. Here is my code.
Dim myService As New AIMWS.DataServ1 Wse
Dim proxyObject As New System.Net.WebP roxy(m_strURLLo cation, True)
myService.Proxy = proxyObject
myService.Ping( )
<System.Web.Ser vices.Protocols .SoapDocumentMe thodAttribute(W ebServiceAddres s
& "/Ping", RequestNamespac e:=WebServiceAd dress,
ResponseNamespa ce:=WebServiceA ddress,
Use:=System.Web .Services.Descr iption.SoapBind ingUse.Literal,
ParameterStyle: =System.Web.Ser vices.Protocols .SoapParameterS tyle.Wrapped)> _
Public Function Ping() As Integer
Dim results() As Object = Me.Invoke("Ping ", New Object(-1) {})
Return CType(results(0 ),Integer)
End Function
<WebMethod()> Public Function Ping() As Integer
If Authenticater() Then
' Just make sure that Ping works, to see if the web service is
valid
End If
End Function
Private Function Authenticater() As Boolean
Dim requestContext As SoapContext = HttpSoapContext .RequestContext
Dim userToken As UsernameToken
Dim returnValue As String
If requestContext Is Nothing Then
Throw New SoapException(" Non-SOAP Message - Are you a hacker?",
SoapException.C lientFaultCode)
End If
For Each userToken In requestContext. Security.Tokens
If TypeOf userToken Is UsernameToken Then
If userToken.Passw ordOption = PasswordOption. SendHashed Then
Return True
Exit For
Else
Throw New SoapException(" Password must be hashed",
SoapException.C lientFaultCode)
End If
End If
Next
End Function
--
Thanks,
JeffS