473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Pass parameters to java webservice from c#.net

Below are 2 ways i tried but m not able to pass parameters to the web service

Expand|Select|Wrap|Line Numbers
  1. <1>
  2. Uri address = new Uri("http://203.88.135.58:8083/JLLSFAServer/SalesForceAutomation/loginVerification");  
  3.  
  4.         // Create the web request  
  5.         HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;  
  6.  
  7.         // Set type to POST  
  8.         request.Method = "POST";
  9.         request.ContentType = "application/x-www-form-urlencoded";  
  10.  
  11.         // Create the data we want to send  
  12.         string appId = "loginName";
  13.         string context = "password";  
  14.  
  15.  
  16.         StringBuilder data = new StringBuilder();
  17.         data.Append("loginName=" + HttpUtility.UrlEncode("E000002028"));
  18.         data.Append("&password=" + HttpUtility.UrlEncode("49505152"));  
  19.         //data.Append("&query=" + HttpUtility.UrlEncode(query));  
  20.  
  21.         // Create a byte array of the data we want to send  
  22.         byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());  
  23.  
  24.         // Set the content length in the request headers  
  25.         request.ContentLength = byteData.Length;  
  26.  
  27.         // Write data  
  28.         Stream postStream = request.GetRequestStream();
  29.             postStream.Write(byteData, 0, byteData.Length);
  30.  
  31.  
  32.         // Get response  
  33.         using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)  
  34.         {  
  35.          // Get the response stream  
  36.          StreamReader reader = new StreamReader(response.GetResponseStream());  
  37.  
  38.          // Console application output  
  39.           string results=reader.ReadToEnd();  
  40.         }  
  41.  
  42.  
  43.  
  44. <2>
  45. WebClient request = new WebClient();
  46.             string data = "E000002028";
  47.             string password = "49505152";
  48.             string postData = "{\"loginName\":\"" + data + "\"" + "&\"password\":\"" + password + "\"}";
  49.             byte[] bytearray = Encoding.UTF8.GetBytes(postData);
  50.  
  51.             request.Headers.Add("Content-Type", "application/json");
  52.  
  53.             string results= request.UploadString("http://203.88.135.58:8083/JLLSFAServer/SalesForceAutomation/loginVerification", "POST", postData);
  54.  
  55.  
  56.  

Its returning 4 which webservice returns when login name is invalid.
Can anyone help me in this??
Is the parameter passing way correct??
Apr 5 '12 #1
0 1796

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Xiao Quan | last post by:
i programed a java webservice, and a client by MS SOAP Toolkit. it work well. Howerver, a .net client cann't access the java webservice and report the following exception: unhandled...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
4
by: luckyabhishek | last post by:
Hi I am using a java webservice in a .NET application. The xml type of a field in this webservice is xsd:datetime. When i call the webservice from the application i get a deserialization error on...
2
by: zmbharmal | last post by:
I have a .NET client My vendor has a Axis/Java Webservice I am able to pass the parameters to their webmethod. They can read it. When they return a Response, it is coming as NULL. The webservice...
0
by: raghuraman_ace | last post by:
Hi i have started a webservice wich has a webmethod with parameters using literal encoding & encoded encoding . The webservice is compiled successfully . But i don know how to pass the...
0
jeffbroodwar
by: jeffbroodwar | last post by:
hi, i need help about consuming webservice created in java with vb6. i've created the webservice in netbeans with sun java server bundle and used MS Soap toolkit 3.0 on the client side. i've...
2
jeffbroodwar
by: jeffbroodwar | last post by:
hi, i need help about consuming webservice created in java with vb6. i've created the webservice in netbeans with sun java server bundle and used MS Soap toolkit 3.0 on the client side. i've...
0
jeffbroodwar
by: jeffbroodwar | last post by:
hi, i need help about consuming webservice created in java with vb6. i've created the webservice in netbeans with sun java server bundle and used MS Soap toolkit 3.0 on the client side. i've...
5
jeffbroodwar
by: jeffbroodwar | last post by:
hi, i need help about consuming webservice created in java with vb6. i've created the webservice in netbeans with sun java server bundle and used MS Soap toolkit 3.0 on the client side. i've...
0
jeffbroodwar
by: jeffbroodwar | last post by:
Hi, i'm currently working on a project that involves vb6 to consume java webservice... i had a problem figuring out how to establish the connection. Fortunately i was able to get this thing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.