How to make program for a server to send the XML?

zouzanda

New member
Joined
Mar 9, 2021
Messages
4
Programming Experience
1-3
HTTP/1.1 200 OK\r\n:
Transmission Control Protocol, Src Port: 8080, Dst Port: 39628, Seq: 1, Ack: 879, Len: 478
Hypertext Transfer Protocol
    HTTP/1.1 200 OK\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
            [HTTP/1.1 200 OK\r\n]
            [Severity level: Chat]
            [Group: Sequence]
        Response Version: HTTP/1.1
        Status Code: 200
        [Status Code Description: OK]
        Response Phrase: OK
    Content-Type: text/xml; charset=utf-8\r\n
    Content-Length: 357\r\n
        [Content length: 357]
    Connection: close\r\n
    Server: Jetty(6.1.26)\r\n
    \r\n
    [HTTP response 1/1]
    [Time since request: 0.129351000 seconds]
    [Request in frame: 96]
    [Request URI: http://xxxxxxxxxx/WS_STG/WS_STG.asmx]
    File Data: 357 bytes
eXtensible Markup Language
    <soapenv:Envelope
        xmlns:soapenv="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/"
        xmlns:ws="http://xxxxxxxxxxxxxxxxxxxxxxxxxx">
        <soapenv:Header/>
        <soapenv:Body>
            <ws:UpdateRequestStatusResponse>
                <ws:UpdateRequestStatusResult>
                    true
                    </ws:UpdateRequestStatusResult>
                </ws:UpdateRequestStatusResponse>
            </soapenv:Body>
        </soapenv:Envelope>
 

zouzanda

New member
Joined
Mar 9, 2021
Messages
4
Programming Experience
1-3
C#:
private void button1_Click(object sender, EventArgs e)
        {

            System.Net.WebRequest req = null;
            System.Net.WebResponse rsp = null;
            try
            {
                string uri = txtURI.Text;
                req = System.Net.WebRequest.Create(uri);
                req.Method = "POST";

                req.ContentType = "text/xml; charset=utf-8";

                System.IO.StreamWriter writer =
            new System.IO.StreamWriter(req.GetRequestStream());
                writer.WriteLine(txtXMLData.Text);
                writer.Close();
                rsp = req.GetResponse();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (req != null) req.GetRequestStream().Close();
                if (rsp != null) rsp.GetResponseStream().Close();
            }
        }





i already tried this code but it is not giving me same result

thanks in advance for the help
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
2,892
Location
Chesapeake, VA
Programming Experience
10+
You'll need to be a bit more descriptive about "but it is not giving me the same result". What result are you getting? What result were you expecting to see?
 

zouzanda

New member
Joined
Mar 9, 2021
Messages
4
Programming Experience
1-3
this is the result i am getting:
Transmission Control Protocol, [2 Reassembled TCP Segments (518 bytes): #59(152), #73(366)]
Hypertext Transfer Protocol
    POST /WS_STG/WS_STG.asmx HTTP/1.1\r\n 
    Content-Type: text/xml\r\n
    Host: xxxxxxxxxxxxxxx\r\n
    Content-Length: 366\r\n
    Expect: 100-continue\r\n
    Connection: Keep-Alive\r\n
    \r\n
    [Full request URI: http://xxxxxxxxxxxxxxxxxxxxxxxxxxx]
    [HTTP request 1/1]
    [Response in frame: 79]
    File Data: 366 bytes
eXtensible Markup Language
    <soapenv:Envelope
        xmlns:soapenv="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
        xmlns:ws="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
        <soapenv:Header/>
        <soapenv:Body>
            <ws:UpdateRequestStatusResponse>
                <ws:UpdateRequestStatusResult>
                    true
                    </ws:UpdateRequestStatusResult>
                </ws:UpdateRequestStatusResponse>
            </soapenv:Body>
        </soapenv:Envelope>
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
2,892
Location
Chesapeake, VA
Programming Experience
10+
Perhaps I'm just blind, but to me the SOAP response looks the same. What's the exact problem with that response that you got back?
 

32x0LF

New member
Joined
Mar 25, 2021
Messages
3
Programming Experience
1-3
have you tried adding this one after
C#:
 rsp = req.GetResponse();

C#:
string result =string.Empty;
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
    result = streamReader.ReadToEnd();
}
it's up to you how you will pass the result
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
2,892
Location
Chesapeake, VA
Programming Experience
10+
Close, but not quite.

The issue is that the trace in post #1 shows a trace of a response. The trace in post #4 shows the trace of a request, which is backed up by the code in post #2 doing a request. If the OP wanted both traces to be similar, he should be doing a response, not a request. But the question is going to be what is going initiate the request to his program so that he can write the appropriate response into the same TCP/IP stream?
 
Top Bottom