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 9240499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:12:01+00:00 2026-06-18T08:12:01+00:00

I have to use provided Java web service. But the problem is custom HTTPHeaders

  • 0

I have to use provided Java web service. But the problem is custom HTTPHeaders are required by this service. I have searched for solutions. I think that this one would work if I could add reference. But when I try to add reference to the service I get the following error:

There was an error downloading 'http://.....'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'http://......'.
The remote server returned an unexpected response: (400) Bad Request.
The remote server returned an error: (400) Bad Request.
If the service is defined in the current solution, try building the solution and adding    the service reference again.

I think security server doesn’t let me access to metadata.
I have tried this solution provided at MSDN and added custom headers like below:

    // Create a request using a URL that can receive a post. 
    WebRequest request = WebRequest.Create("http://....");
    // Set the Method property of the request to POST.
    request.Method = "POST";
    // Create POST data and convert it to a byte array.

    string postData = string.Empty;
    using (StreamReader contentReader = new StreamReader("D:\\test.txt"))
    {
        postData = contentReader.ReadToEnd();
    }

    //Add headers to request
    request.Headers.Add("UserName", "myUserName");
    request.Headers.Add("Password", "myPassword");
    request.Headers.Add("SomeCustomHeader", "myCustomHeaderValue");

    //string postData = "This is a test that posts this string to a Web server.";
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    // Set the ContentType property of the WebRequest.
    request.ContentType = "text/xml";
    // Set the ContentLength property of the WebRequest.
    request.ContentLength = byteArray.Length;
    // Get the request stream.
    Stream dataStream = request.GetRequestStream();
    // Write the data to the request stream.
    dataStream.Write(byteArray, 0, byteArray.Length);
    // Close the Stream object.
    dataStream.Close();
    // Get the response.
    WebResponse response = request.GetResponse();
    // Display the status.
    Console.WriteLine(((HttpWebResponse)response).StatusDescription);
    // Get the stream containing content returned by the server.
    dataStream = response.GetResponseStream();
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(dataStream);
    // Read the content.
    string responseFromServer = reader.ReadToEnd();


    using (StreamWriter resultWriter = new StreamWriter("D:\\result.xml"))
    {
        resultWriter.Write(responseFromServer);
    }

    // Display the content.
    //Console.WriteLine(responseFromServer);
    // Clean up the streams.
    reader.Close();
    dataStream.Close();
    response.Close();

    Console.ReadLine();

and it worked for me. I can get result from service now (as xml files), and I also have WSDL. So I think I can parse this results to appropriate objects. But I want to be able to add service reference and use it like a normal service. I mean calling methods with their names, not using SOAP messages, and getting results as parsed objects.
Is there any workaround? Thanks in advance.

  • 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-18T08:12:01+00:00Added an answer on June 18, 2026 at 8:12 am

    you can create a proxy class using wsdl.exe tool. check this out http://msdn.microsoft.com/en-us/library/aa529578.aspx

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

Sidebar

Related Questions

I have a java web app that makes back-end use of a third-party web
I have written REST web service in netbean IDE using jersey framework and java.
We have to create a web service client using Apache CXF in Java. The
I am invoking HTTPS SOAP web service through java code. I have already imported
I have use semantic-analyze-proto-impl-toggle to switch between the function's proto and impl, but when
I have use the TryUpdateModel method on the controllers but now I need to
Hello I have use DOMDocs in the past but I am stuck how to
Telephone Manager give me Null phone number while i have use this code -
i make one class file for jar. and this class have use wurfl. and
I have a question about MIMEParsingException. I use Java EE 6 with NetBeans 6.8.

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.