Solved

Get values parameters from WSDL file

Posted on 2009-03-31
15
1,514 Views
Last Modified: 2012-05-06
Hello Folks:

I need to get values from a WSDL file.
I've a site project in visual studio and I added a CRM web services like a Web Reference.

I dont know how to get values/parameters in C#.
My idea is in C# create a call to that web service.

I need an example or link to see how to do it.

thank you
0
Comment
Question by:nkoriginal
  • 8
  • 7
15 Comments
 
LVL 3

Expert Comment

by:JenniQ
ID: 24033634
Getting Started With .NET Web Services

There are two technologies in current use for creating and consuming web services in .NET. These are the ASMX or XML Web Services, and Windows Communication Foundation, or WCF.
 
A good starting point for ASMX web services is Using ASP.NET Web Services. Specifically, see Web References in Visual Studio and How to: Add and Remove Web References.

Now, the ASMX web service technology is the older techology from Microsoft. The new way to do web services in .NET is WCF. There's an excellent portal to WCF at http://msdn.microsoft.com/wcf. In particular, see Windows Communication Foundation, Conceptual Overview, and Getting Started Tutorial.

There are a few other Microsoft web service technologies I will mention only to warn you away from. They are obsolete and should not be used for new development. In fact, anyone using the following technologies should migrate to WCF as soon as possible.

Web Service Enhancements, or WSE were a set of stopgap releases that added to the ASMX technology to permit developers to work with the emerging WS-* standards as they were being developed by the industry. That means you will often find WSE mentioned in conjunction with security. This does not mean that WSE is the solution to security in web services, it means that WSE was that solution until WCF was released. WCF supersedes WSE, which is now obsolete.

Even more obsolete is the SOAP Toolkit. This was a way to create clients for web services, and worked for old VB or ASP applications. Do not use it.
0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24033731
yes, you right.
I reading about that, like you said., the WSDL is an old technology.
but in the company i working, they' using that technology, and I need to work with that.
that's the reason I need a code or an example, to get values/parameters from a Web Reference WSDL.

I added that web services to my project but i dont have any idea how to work in C# to get the values.

thanks for your help
0
 
LVL 3

Expert Comment

by:JenniQ
ID: 24033785
OK so are you talking about the query string parameters sent to the WDSL? What extension is the web service ur trying to hit / grab data from?

Are you trying to read the return values from the web service? Consume, expose, or edit?

-- jq
0
 
LVL 3

Expert Comment

by:JenniQ
ID: 24033820
Consumers of a Web Service need to know what the service offersfor example, what its Web callable method look like. Therefore, all Web Services optionally share another common XML document: a contract (note, Web Services built with ASP.NET always have a contract provided automatically).

If you hit the WS (it should be an ASMX or something) then it will show you the parameters it exposes.

If you see XML, then this web service returns XML.

Tools can use this XML schema to build proxy classes for ur Web Service. A proxy class is a class that looks and feels like a local object, but it is in fact doing the work to serialize, send, receive, and de-serialize our method request to a SOAP endpoint.

SOAP is prolly the route you wanna go. Let me know more and i can give u a code sample.

- jq
0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24033853
I added the file webservice.wsdl. that's the file name.
Is a web services from CRM Sage application.

Right now I've that file in my project but I dont know how to interact with that file from C# file.
I need to setup the values (I will get them from the manual) and then return the values.

thanks again for your help
0
 
LVL 3

Expert Comment

by:JenniQ
ID: 24033908
1. Open the Solution Explorer in my project.
2. Right click on it and choose "add web reference"
3. A pop window appears.
4. In URL box, instead of type the web site address, enter the exact location of your wsdl file. The file, not path and don't forget to type the extension.
5. Click on "Go"
6. If everything's all right Visual Studio will recognize the wsdl and procedures inside.
7. All you have to do now is just label it to whatever you want.
8. Click "Add Reference"
9. Back to Solution Explorer window, you should see the wsdl file appears under WebReference node. You can now consume it in the same way as any other reference file.

Yeah, use the "MyWSDL test = New MyWSDL();" in C#.
0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24033964
Jenni, thanks so much for your help. Is really good to start.
I will try it.

one more question, do you know how to get a value from that web service??
i found something like this, but Im a little confusing

If I put this:

String strCompanyID = Request.QueryString.Get("key1");
queryentityresult CompanyQueryResult = myCRM.queryentity(int.Parse(strCompanyID), "Company");
ewarebase CRMBase;
CRMBase = CompanyQueryResult.records;
company myCompanyRecord = (company)CRMBase;

I will get the companyID value, right?
but I dont understand how this code interact with the web service.
maybe Im so tired.

Sorry for this dumb question.
Thanks
myCRM.SessionHeaderValue = new SessionHeader();

myCRM.SessionHeaderValue.sessionId = Request.QueryString.Get("SID");

getversionstringresult CRMVersion = myCRM.getversionstring();

//Response.Write(CRMVersion.versionstring);
 

String strCompanyID = Request.QueryString.Get("key1");

queryentityresult CompanyQueryResult = myCRM.queryentity(int.Parse(strCompanyID), "Company");

ewarebase CRMBase;

CRMBase = CompanyQueryResult.records;

company myCompanyRecord = (company)CRMBase;
 

CompanyNameData.Text = myCompanyRecord.name;

COMPSLADATA.Text = myCompanyRecord.slaid;

CompWebSiteData.Text = myCompanyRecord.website;

CompTypeData.Text = myCompanyRecord.type; 

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:JenniQ
ID: 24034043
Haha that is confusing.

Try:

Response.Write(Request.QueryString["key1"]);

So are you trying to get a parameter out of the webserivce ONCE SOMEONE HITS IT?

Consuming it... the webservce woudl not be in ur project.

So you must want to get the parameters inside the web service? Can you open the webservice and edit the code? If so, then in the WSDL file (or asmx) you add logic to get parameters.

Let me know which path ur taking.


0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24034477
the web service is from external application.
when I added the web reference, I put the link to that web service, like this:
http://www.myserver.com/app/ws/webservices.wdsl
So that web reference is in my project.
My idea is to get values from that webservice, because the external application works with SQL DB and I need to get colums and values from that columns.
So i need to setup the parameters and then get the values.

I dont know if I explanied good or not, my english is not so good.

thanks
0
 
LVL 3

Accepted Solution

by:
JenniQ earned 500 total points
ID: 24034563
OK got it,.

So add the WSDL as a reference in ur project, then create a new OBJECT with that Type.

Then you can get to all the parameters as properties. So if you named your reference "WorldTime" then this is how you'd "Consume" it:

        //Create instace of the WorldTime.dll
        WorldTime Time= new WorldTime();

        //get input from user
        Console.Write("Enter City: ");
        string City=Console.ReadLine();

        //gets date and time
        string DateTime=Time.GetTime(City);

        //write the citys time and date
        Console.WriteLine(DateTime);

Cuz WorldTime WSDL exposes those properties.

Does that make sense?
0
 
LVL 3

Expert Comment

by:JenniQ
ID: 24034569
Here is the PERFECT link for you my friend!

http://articles.techrepublic.com.com/5100-10878_11-5768122.html

-- jq
0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24034585
Genius!
You make a really good explanation, and Im really more clear in what I need to do.
Thank you so much JenniQ.

The last comment clarify how the web service works and how to get the data. With that information  I can start.

thank again!!!
:D:D:D
0
 
LVL 5

Author Closing Comment

by:nkoriginal
ID: 31565062
Really good answer. Excellent explanation to my question. Clear and easy solution. Thanks
0
 
LVL 3

Expert Comment

by:JenniQ
ID: 24034618
ha ha! I'm soo glad I could help.

Now go get some rest.
0
 
LVL 5

Author Comment

by:nkoriginal
ID: 24034650
JenniQ, If I open another question you can help?
Is not relative to this problem, is something I want to know..(create an stored procedure to insert automatically information in the SQL DB?).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now