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

  • Home
  • SEARCH
  • 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 8476475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:11:23+00:00 2026-06-10T18:11:23+00:00

I have to request a URL i.e. http://192.168.220.12:5000 where a java service will receive

  • 0

I have to request a URL i.e. “http://192.168.220.12:5000” where a java service will receive it,

with following string as Body

<?xml version='1.0'?><!DOCTYPE svc_init SYSTEM 'ABCD.DTD'><svc_init ver='3.3.0'><hdr ver='3.3.0'><client><id>xxx</id><pwd>xxx</pwd></client></hdr><aaaa ver='3.3.0'><trans_id>1</trans_id><request_type type='2'/><l_hor_acc type='HIGH'/></aaaa></svc_init>

I am able to do it successfully with RESTClient from my firefox browser, see the image below:
enter image description here
But when I send it through following C# code it gives me following error:

 java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(Unknown Source)
    at Creader.run(Creader.java:42)

C# code is as follows:

xmlData= "<?xml version='1.0'?><!DOCTYPE svc_init SYSTEM 'ABCD.DTD'><svc_init ver='3.3.0'><hdr ver='3.3.0'><client><id>xxx</id><pwd>xxx</pwd></client></hdr><aaaa ver='3.3.0'><trans_id>1</trans_id><request_type type='2'/><l_hor_acc type='HIGH'/></aaaa></svc_init>";

address = "http://192.168.220.12:5000";

using (var client = new WebClient())
{
  client.UploadData(address , Encoding.ASCII.GetBytes(xmlData));
}

What am I doing wrong here?

I also tried following but nothing worked.
1) Convert xmlData to byte [] using another method .
2) used Encoding.UTF8.GetBytes instead of Encoding.ASCII.GetBytes.
3) used client.UploadString(new Uri(mlcAddress), xmlData) instead of client.UploadData…

  • 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-10T18:11:24+00:00Added an answer on June 10, 2026 at 6:11 pm

    Following code (TCP socket) worked

    oSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
                    ProtocolType.Tcp);
    System.Net.IPAddress oIPAddress = System.Net.IPAddress.Parse(ip);
    System.Net.IPEndPoint oEndPoint = new System.Net.IPEndPoint(oIPAddress, port);
    oSocket.Connect(oEndPoint);
    
    Object oData = xmlData;
    byte[] bData = System.Text.Encoding.ASCII.GetBytes(oData.ToString());
    oSocket.Send(bData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have an AJAX request like this: $.ajax({ url: http://192.168.0.100/, success: function(x) {
I have following code: def whatever(url, data=None): req = urllib2.Request(url) res = urllib2.urlopen(req, data)
A web browser is calling my action with the following URL; Request URL:http://localhost:4000/MyController/UrlCheck?Menu.Url=sometext My
I have request $.ajax({ url: 'http://translate.google.ru/translate_a/t', data: { client: x, text: sourceText, sl: langFrom,
STACkers... I have a webserver with shared folder... It's address is: http://192.168.1.1:9999/folder/0 I have
I want to get only the headers of an URL request. I have been
I have a very simple ajax request: $.get(url, data) .done(function () { }) .fail(function
hie i have a html form and while posting a request to a url
I need to make a cURL request to a https URL, but I have
I have an object in my controller @data=<meta property=\og:url\ content=\<%=SITE_URL%><%=request.request_uri%>\ />.html_safe When I print

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.