IT Community - Software Programming, Web Development and Technical Support

WebServices in DotNet

This is a discussion on WebServices in DotNet within the ASP and ASP.NET Programming forums, part of the Web Development category; Here is a sample code for that Ramesh.... Go thru this... Code: HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = &...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 09-05-2007, 12:19 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

Here is a sample code for that Ramesh....


Go thru this...

Code:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.Method = "PUT";
            request.ContentType = ContentType // Here is ur ContentType
            request.ContentLength = byteArr.Length;
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArr, 0, byteArr.Length);
            dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 09-05-2007, 12:34 AM
raja raja is offline
D-Web Trainee
 
Join Date: May 2007
Posts: 34
raja is on a distinguished road
Question Re: WebServices in DotNet

Hi there,

I need a PHP web service for C#. IS there any possible for that?

How can I create a PHP Web Service for C#?

can anybody clear me?
__________________
Raja. Myblog
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 09-05-2007, 12:50 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

Yes....

You can create php web service for C#. Here is sample code...

Code:
//ws.php

require_once("lib/nusoap.php"); 
$ns="http://your.server.address/"; 

$param = array('x' => 'xsd:string','y' => 'xsd:string'); 
$return = array('return'=>'xsd:string'); 

$server = new soap_server(); 
$server->configureWSDL('WS Test',$ns); 
$server->wsdl->schemaTargetNamespace=$ns; 
$server->register('TestFunction',$param,$return,$ns); 

function TestFunction($x,$y){ 

$ret=$x+$y; 

return new soapval('return','xsd:string',$ret); 
} 

$server->service($HTTP_RAW_POST_DATA);
For more visit the following...

Random Byte: Creating a php webservice for C#
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 09-05-2007, 01:00 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Exclamation Re: WebServices in DotNet

Hi Vinoth,


Thanks for ur kind reply...

It's working for me...but...

Can u clear me the contenttype?

I need to upload image files with the format of Jpg....

thnx in advance!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 09-05-2007, 01:18 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

Ya sure Ramesh!

The ContentType property sets the HTTP content type for the request and response object.

ContentType for Text is

Code:
ContentType = "text/plain"
ContentType for XML is

Code:
Contenttype="text/xml"
ContentType for HTML is

Code:
Contenttype="text/html"
ContentType for icon is

Code:
application/x-mmc.icon;
ContentType for BMP is

Code:
img/bmp
ContentType for RingTone is

Code:
application/x-mmc.ringtone
ContentType for Audio is

Code:
audio/wav
ContentType for JPEG is

Code:
ContentType="image/JPEG"
ContentType for TIFF is

Code:
ContentType ="image/tiff"

and so on...
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26 (permalink)  
Old 09-05-2007, 02:03 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Cool Re: WebServices in DotNet

Thanks Vinoth.

I got it what I need....

I uploaded my image in my http.

once again thnx....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27 (permalink)  
Old 09-05-2007, 03:56 AM
jeyaprakash.c jeyaprakash.c is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 228
jeyaprakash.c is on a distinguished road
Question Re: WebServices in DotNet

I am trying to make a client in C# that use a PHP Web Service.

I am using NuSOAP for creating the Web Services. It creates the WDSL ok and C# recognizes it but during run Time its throws an exception.

Has anybody tryied to interoperate with PHP web services and C# client ?

Please let me know your experience.
__________________
thanx n regards
jeyaprakash.c
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28 (permalink)  
Old 09-05-2007, 06:40 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

while it has PHP in it, C# is the one throwing an exception so it's a C# problem.

Check it out in C# programme....
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29 (permalink)  
Old 09-05-2007, 06:54 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

Getting the Webservice running on the .NET server is easy. The hard part was getting the PHP page to call the webservice and return the values that we needed.

Here is a demo method:

Code:
[WebMethod] public Order GetOrder() { Order myOrder = new Order(); myOrder.SalesNum = “123″; myOrder.OrderDate = “05/24/2006″; myOrder.ShipDate = “Tomorrow”; myOrder.PaymentRec = “05/24/2006″; myOrder.OrderStatus = “InProgress”; return myOrder; }
Learn with my posts.....
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30 (permalink)  
Old 09-05-2007, 06:59 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

$result is the return var from the webservice $result[’GetOrderResult’][’SalesNum’] $result[’GetOrderResult’][’OrderDate’] etc…


for more see the following link....

Random » PHP calling C# .NET Webservice
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #31 (permalink)  
Old 09-06-2007, 12:53 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Question Re: WebServices in DotNet

Hi all,

How can I return IList from a WebService?

I hv tried a lot of time. I can't return IList but I can return arraylist.

Is any sample code for that? Could u pls let me know....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #32 (permalink)  
Old 09-06-2007, 01:16 AM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Red face Re: WebServices in DotNet

I've noticed that XmlSerializer won't serialize objects that implement IDictionary by default.

you can visit this msdn link for reference.

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

It might be useful for you. Read the last question and answer in the link.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #33 (permalink)  
Old 09-06-2007, 01:19 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

WebMethod framework uses the XmlSerializer plumbing, it's now possible to return DictionarySerializer objects from WebMethods.

For example, let's consider the WebMethod that returns a Hashtable through a DictionarySerializer wrapper as shown in the following code:

Code:
[WebMethod]
public DictionarySerializer GetHashTable()
{
    Hashtable ht = new Hashtable();
    ht.Add(1, "Aaron");
    ht.Add(2, "Monica");
    ht.Add(3, "Michelle");
    return new DictionarySerializer (h1);
}
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #34 (permalink)  
Old 09-06-2007, 01:41 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

The XmlSerializer errors when serializing an object with a public property of type IList<T>. Since IList<T> is an ICollection, this should work.

Also, it similarly errors when using properties that are of any interface type that inherits from IList<T>. Making that interface explicitly implement IEnumerable doesn't work either (even though the documentation implies that this should work).


XmlSerializer does not support members of type ICollection or IEnumerable since V1. It requires that all members typed to collection types have a default indexer and Add method. ICollection and IEnumerable both do not have Add methods.

In the following msdn link explains about this error.....

Feedback: XmlSerializer can't serialize properties of type IList<T>
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #35 (permalink)  
Old 09-06-2007, 06:42 AM
raja raja is offline
D-Web Trainee
 
Join Date: May 2007
Posts: 34
raja is on a distinguished road
Question Re: WebServices in DotNet

Hi friendz,

I have web service written on C#
I want call this service from code on C/C++ (I want that this code stably working)


What is better way to do this call? What framework better use? Axis C++ 1.x or Axis2C ???
__________________
Raja. Myblog
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #36 (permalink)  
Old 09-06-2007, 07:19 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Red face Re: WebServices in DotNet

Well I cannot comment on the suitability of Axis2 C++, because I did not use it for some time. And I could not test it with C#.

But on Axis2/C, you can interop with .NET. Also, if you want WS-* stuff, such as WS-Addressing, WS-Security and WS-RM, then you would be better off using Axis2/C as it has proved to work with .NET with those specs.
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #37 (permalink)  
Old 09-07-2007, 03:40 AM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Question Re: WebServices in DotNet

Hello,

I have created a web service and am trying to use it in a Windows application. But I'm getting the error when I run my code as follows,

The request failed with HTTP status 401: Unauthorized.

I've created a virtual directory in IIS and am trying to run it locally.

Any thoughts would be great.

Here is my code:



private void button1_Click(object sender, EventArgs e)
{

myService.Service service=new myService.Service();
MessageBox.Show(service.Message());
}


Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #38 (permalink)  
Old 09-07-2007, 05:39 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Red face Re: WebServices in DotNet

Have you set the virtual directory so that allows anonymous authentication?

You should Allow access for the IIS anonymous user.
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #39 (permalink)  
Old 09-07-2007, 06:31 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: WebServices in DotNet

Hi friend,

If Anonymous is allowed then you need to check permissions on your application folder. Give Network services and ASP.NET user permisison. And if your Web Service uses other resources like writing to file etc you need to check permission to those resources.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #40 (permalink)  
Old 09-07-2007, 08:09 AM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Question Re: WebServices in DotNet

This might seem like a silly questions.

We are moving web service from out test service to production.Now my Web Application is referencing Web Service on the test server. When i move my application to production, i would like to reference the production server instead. Would it be possible to change the reference link by changing the link to the web service through web.config?
__________________
Krishnakumar.S
Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy Property Class Generator for DOTNET Developers Anandavinayagam ASP and ASP.NET Programming 4 01-16-2008 03:54 AM
What is Ngen.exe in DotNet? leoraja8 VB.NET Programming 11 10-31-2007 02:17 AM
OOPs Tips for DotNet. S.Vinothkumar Interview Questions & Answers and Tips 11 10-29-2007 07:20 AM
Transaction Scope in DotNet using C#. S.Vinothkumar C# Programming 52 09-22-2007 01:15 AM
Does Using Json Instead Of Xml Speeds Up Webservices Architecture ramkumaraol HTML, CSS and Javascript Coding Techniques 0 07-18-2007 02:59 AM


All times are GMT -7. The time now is 02:58 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0