Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8432433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:07:31+00:00 2026-06-10T06:07:31+00:00

I have to sent the XML document as an parameter to request an WebRequest

  • 0

I have to sent the XML document as an parameter to request an WebRequest using the Post method and get response. Web service implements the following method:

public string Register(XmlDocument register){...}

I’m trying doing like this , but I can’t get response and I’m not sure that my code is working =(

HttpWebRequest request = HttpWebRequest.Create("http://ws2.sti.gov.kg/TRKService/PatentService.asmx/Register") as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

Encoding ex = Encoding.GetEncoding("iso-8859-1");
XmlDocument doc = new XmlDocument();
doc.LoadXml("<foo><bar>baz</bar></foo>");
string rawXml = doc.OuterXml;

string requestText = string.Format("register={0}", HttpUtility.UrlEncode(rawXml, ex));

Stream requestStream = request.GetRequestStream();
StreamWriter requestWriter = new StreamWriter(requestStream, ex);
requestWriter.Write(requestText);            
requestWriter.Close();

Maybe someone has a working example?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:07:33+00:00Added an answer on June 10, 2026 at 6:07 am

    403 Error

    If your getting a 403 when trying to import the web service this may not be your fault. Try
    looking at the wsdl file in your web browser. If you still get the 403 error then their is no use coding any further because you don’t have permission to use that service.

    Code Syntax

    Also, in your code I it appears your not reading back the response anywhere. Your last statement writes the XML to the stream but your not reading back the response anywhere.

    requestWriter.Write(requestText);            
    requestWriter.Close();
    

    SOAP

    If the web service your are communicating with is SOAP based then your XML payload needs to conform to the SOAP standard. Your sample code above uses very basic XML, probably because it’s just an example, but for it to work you will need requests with a format along the lines of

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GetWeather xmlns="http://www.webserviceX.NET">
          <CityName>string</CityName>
          <CountryName>string</CountryName>
        </GetWeather>
      </soap:Body>
    </soap:Envelope>
    

    Not

    <foo><bar>baz</bar></foo>
    

    Again, you’ve obviously only used foo for an example but this could also be the source of your problem so inspect the actual XML payload you are sending.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web service to which I send a xml request (application/x-www-form-urlencoded encoded)
I have an XML document being sent to me by HTTP POST: <?xml version=1.0
I have the following xml that's sent to me from a web service. I'm
I have a WCF web service which is responsible for managing work sent from
I have a web service that requires special headers to be sent in the
I'm using REXML to parse through some XML data sent via POST. The XML
Is there any solution to detecting if a POST have been sent with jQuery?
I have a server-sent events handler in ASP.NET Response.ContentType = text/event-stream; while (true) {
I have a linux C program that handles request sent to a TCP socket
I have a .Net webserivce that accepts XML in string format. XML String sent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.