![](https://www.xtremedotnettalk.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
groads2
Members-
Posts
16 -
Joined
-
Last visited
About groads2
- Birthday 09/12/1961
groads2's Achievements
Newbie (1/14)
0
Reputation
-
My application uses httpwebrequest class to access a secured service. I have received a certificate which I installed on the pc. the web service requires a username and password. I get the following message when running the app: "The underlying connection was closed. Could not establish trust relationship for the SSL/TLS secure channel" My code is below but I don't know what is wrong or what else to do. Thanks. Dim cert As System.Security.Cryptography.X509Certificates.X509Certificate cert = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile("c:\was33.cer") Dim defaultUri As String = String.Empty defaultUri = "https://111.111.11.11:999/services/queryservice" Dim query As String = String.Empty Dim urii As String = String.Empty Dim postData As String = String.Empty Dim responseData As String = String.Empty Dim hwrequest As System.Net.HttpWebRequest urii = defaultUri hwrequest = System.Net.HttpWebRequest.Create(urii) hwrequest.Method = "POST" hwrequest.Accept = "gzip, deflate" hwrequest.ContentType = "text/xml; charset=utf-8" hwrequest.Timeout = 20000 hwrequest.Credentials = New System.Net.NetworkCredential("psc8", "psw8") hwrequest.ClientCertificates.Add(cert) If Not String.IsNullOrEmpty(txtQuery.Text) Then postData = txtQuery.Text End If Dim encoding As New Text.ASCIIEncoding() 'Use UTF8Encoding for XML requests Dim postByteArray() As Byte = encoding.GetBytes(postData) hwrequest.ContentLength = postByteArray.Length Try Dim postStream As IO.Stream = hwrequest.GetRequestStream() postStream.Write(postByteArray, 0, postByteArray.Length) postStream.Close() Catch ex As Exception txtReply.Text = ex.Message Exit Sub End Try Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse() Try If hwresponse.StatusCode = Net.HttpStatusCode.OK Then Dim responseStream As IO.StreamReader = _ New IO.StreamReader(hwresponse.GetResponseStream()) responseData = responseStream.ReadToEnd() End If Catch ex As Exception responseData = ex.Message.ToString End Try hwresponse.Close()
-
I have a service that uses the tcpClient to send and receive data. I can unplug the network cable and the service does not know the connection has been broken. This is the code that is used to test the connection. The call to send does not throw an error. How can I get my service to know the connection has broken? Any help is greatly appreciated. Private Function IsConnected() As Boolean SyncLock (_sendSyncObject) If Not _tcpClient Is Nothing Then Try If IsConnectionInCloseWait() Then Return False Dim data(0) as byte _tcpClient.Client.Blocking = False _tcpClient.Client.Send(data, 0, 0) Return True Catch ex As SocketException ' 10035 == WSAEWOULDBLOCK If ex.NativeErrorCode.Equals(10035) Then Return True Catch e As Exception Return False Finally If Not _tcpClient Is Nothing AndAlso Not _tcpClient.Client Is Nothing Then _tcpClient.Client.Blocking = True End Try End If End SyncLock Return False End Function
-
IIS hosted WCF service does not work Hi all: I am trying to learn WCF. I have tried serveral examples from the Web which do not work as they were instructed for me. I must be doing something wrong but am not sure what. I have windows 7 home, VS2012. I created a solution call Greetings. In the service I added a class Library where I put the Interface and Service class. To that solution I added a website using the wcf service template type. I added the reference to th greeting class library that has my interface and service class. This is supposed to be hosted by IIS. I wrote a client app to access the service but the error tells me there no service at the endpoint. I am not sure what I am missing. I attached a text file with the contents of my interface, service class,service.svc and web.config. Thanks for the help. MyGreetingServiceInfo.txt
-
I have corrected this error by changing getRequestStream to getResponseStream but have a new problem. This the http header being sent. POST / HTTP/1.1 Accept: text/xml SOAPAction: http://www.webserviceX.NET/GetBookTitles Content-Type: text/xml; charset="utf-8" Host: http://www.webservicex.net Content-Length: 207 Expect: 100-continue Connection: Keep-Alive The request line is not correct. My method is not showing in for the post. I am not sure how to get it there with httpWebRequest
-
I am learning web services and want to get this client working. I get the error "Cannot send a content-body with this verb-type" You can see I have set the method to "POST". The error comes when I try to execute the line with ws.getRequestStream. Any Ideas? Thanks. Public Class Form1 Dim myUrl As String = "http://www.webserviceX.net" Dim ws As System.Net.HttpWebRequest = System.Net.WebRequest.Create(myUrl) Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Try ws.Host = "www.webserviceX.net" ws.Method = "POST" ws.Timeout = 60000 ws.Accept = "text/xml" ws.Headers.Add("SOAPAction", "http://www.webserviceX.NET/GetBookTitles") ' ws.ClientCertificates.Add ws.ContentType = "text/xml; charset=""utf-8""" Dim myxml As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & System.Environment.NewLine & _ "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & System.Environment.NewLine & _ "<soap:Body>" & System.Environment.NewLine & _ "<GetBookTitles xmlns=""http://www.webserviceX.NET"">" & System.Environment.NewLine & _ "</soap:Body>" & System.Environment.NewLine & _ "</soap:Envelope>" Dim myencoder As New System.Text.ASCIIEncoding() Dim myxmlByteArray() As Byte = myencoder.GetBytes(myxml) ws.ContentLength = myxmlByteArray.Length Dim postquerystream As System.IO.Stream = ws.GetRequestStream() postquerystream.Write(myxmlByteArray, 0, myxmlByteArray.Length) postquerystream.Close() Dim response As System.Net.HttpWebResponse = ws.GetResponse() If response.StatusCode = System.Net.HttpStatusCode.OK Then Dim respstream As System.IO.StreamReader = New IO.StreamReader(ws.GetRequestStream()) Dim responsedata As String = respstream.ReadToEnd() Me.TextBox1.Text = responsedata End If response.Close() Catch ex As Exception Dim x As String = ex.ToString End Try End Sub End Class
-
I am trying to learn how to write a web client. I wrote a WCF web client to the same site in the code below and that worked. I would also like to write one similar to the code below. Any ideas on what I am doing wrong would be great. I am getting the error: InnerException = {"Content-Length or Chunked Encoding cannot be set for an operation that does not write data."} Public Class Form1 Dim manualWebClient As New System.Net.WebClient() Private Sub Jack() Handles Button1.Click manualWebClient.Headers.Add("Content-Type", "text/xml; charset=utf-8") manualWebClient.BaseAddress = "http://ws.cdyne.com" Dim reqstr As String = "<s11:Envelope xmlns:s11=""http://schemas.xmlsoap.org/soap/envelope/"">" & System.Environment.NewLine & _ "<s11:Body>" & System.Environment.NewLine & _ "<ns1:GetCityForecastByZIP xmlns:ns1=""http://ws.cdyne.com/WeatherWS/"">" & System.Environment.NewLine & _ "<ns1:ZIP>33569</ns1:ZIP>" & System.Environment.NewLine & _ "</ns1:GetCityForecastByZIP>" & System.Environment.NewLine & _ "</s11:Body>" & System.Environment.NewLine & _ "</s11:Envelope>" ' manualWebClient.Headers.Add("Content-Length", Len(reqstr).ToString) Dim bytArguments As Byte() = System.Text.Encoding.ASCII.GetBytes(reqstr) Try Dim bytRetData As Byte() = manualWebClient.UploadData("/WeatherWS/Weather.asmx", "POST", bytArguments) MessageBox.Show(System.Text.Encoding.ASCII.GetString(bytRetData)) Catch ex As Exception Dim v As String = ex.ToString End Try End Sub End Class
-
Re: web service info links I have made progress. So far I have a simple webservice and client app that consumes the service. so my concept is working. Below is something I did with the real wsdl. Do I actually need access to the other parties site/service to use the wsdl utility? c:\ConnWsdl\wsdl\queries>"c:\Program Files\Microsoft SDKs\Windows\v6.0a\bin\wsdl .exe" InfoQueryService.wsdl Microsoft ® Web Services Description Language Utility [Microsoft ® .NET Framework, Version 2.0.50727.3038] Copyright © Microsoft Corporation. All rights reserved. Error: Unable to import binding 'InfoQueryServiceBinding' from name space 'https://coll.prodis.ct.org/wsdl/queries'. - Unable to import operation 'InfoQueryOperation'. - The element 'https://coll.prodis.ct.org/ctsp/queries/1.0:InfoQueryRequest' is missing.
-
Re: web service info links I have been reading quite a bit about the service and am trying some thing now. This is where I am at. I am running windows7 and using visual webdeveloper express. I have installed IIS on my PC. I created a wcf application with vswe and on the project web properties I checked "use local IIs server". Project url text box I put "http://localhost/wcfwebservice1". Is this correct? I also read on another site to build the project and move the .svc and .config to the virtual directory. But I cannot find the .svc. Where is the virtual directory?
-
Re: web service info links Thanks, this is great. I am and older programmer and lucky to be in the position I am in. This new technology is very different than any thing I have done in the last 30 years and now I am playing catchup. I will get started with this today. If you have any sources or books that I should get, please let me know. Thanks again.
-
My solution is to monitor the IsAlive property on the thread every 30 seconds. Seems to give me what I am looking for. Thanks.
-
We have a service that runs several threads to handle different functions required by the service. One of the functions stops working after several days. I assume the thread no longer exists or is not running. How can I monitor that or tell if a thread no longer exists or is no longer running?
-
Hi all: I have been given a set of schemas and wsdl. I have to write an application that will submit a request to a service and get a response. I don't even know where to begin. Can someone tell me What type of service I am writing and some of the things I may need to do to make use of the schemas and wsdl to make a valid request? I hope this is even enough info for someone to give me some direction of what I can do to start. Please excuse my ignorance. Thanks.
-
I am running windows 7 professional and VS2010. I created a windows service solution which does nothing really just a practice project. It compiles successfully. I used installutil.exe to register the service and it returned messages stating that it installed/registered successfully. But it does not show in my windows services on the control panel>administrative tools> services. What am I missing?
-
I have a form that is instantiated with the following code. When I click the ok or cancel buttons that are on the form I call me.close() but the form does not close. I just stays on my screen and my application is hung. The form is not running on the same thread as the main form. If _frmAppManpower Is Nothing Then _frmAppManpower = New frmAppManpower AddHandler _frmAppManpower.FormClosed, AddressOf OnFormClosed End If With _frmAppManpower .RosterID = rosterID .ApparatusName = apparatusName .TopMost = True .WindowState = FormWindowState.Normal .ShowDialog(whndle) .TopMost = False .Activate() End With
-
I just fixed the problem. One of the other projects that I referenced in this project had a class with property of type system.IntPtr. I had to use the xmlIgnore attribute on the property to correct the problem. Thanks. <Xml.Serialization.XmlIgnore()> _ Public ReadOnly Property WindowHandle() As Nullable(Of IntPtr) Get Return _winHandle End Get End Property