0
votes

I am struggling to resolve this issue, pls help. I have to call REST WCF service to pass an object. Can you tell me a code to see xml format that I am trying to send to service.

Dim request As WebRequest
request = WebRequest.Create("http://localhost:1143/ServiceHost.svc/REST/GetResponseCode")
request.Method = "POST"
request.ContentType = "application/xml; charset=utf-8"

Dim dcs As New DataContractSerializer(GetType(transaction))
Dim xdw As XmlDictionaryWriter = _
        XmlDictionaryWriter.CreateTextWriter(request.GetRequestStream(), Encoding.UTF8)
dcs.WriteObject(xdw, tran)
Dim res As WebResponse = request.GetResponse()
1
"Can you tell me a code" - programming isn't magic. There isn't "a code" to do something. Anyway take a look at Fiddler. - CodeCaster
Thanks, I really want to see what I am trying to send to service. - Chris_web

1 Answers

0
votes

Well. At last found solution. It's a bug in my code and there are no issues with messaging transport. Mistakenly, I have passed Class as a parameter in GetType in above code.

Dim dcs As New DataContractSerializer(tran.GetType())

Also I have closed XmlDictionaryWriter at the end, otherwise 'Request.GetResponse()' timeout will happens.