开发者

How do I call a SOAP based Web Service from within a .asmx page?

开发者 https://www.devze.com 2023-02-24 09:04 出处:网络
I am trying to create a sort of \"bootstrap\" web service using a classic .net C# .asmx page and not WCF.(The business requirements for this project are specific and do not want a WCF service).

I am trying to create a sort of "bootstrap" web service using a classic .net C# .asmx page and not WCF. (The business requirements for this project are specific and do not want a WCF service).

Basically, I am trying to do this:

  1. Create a new web servic开发者_Python百科e (I have no problem doing this)
  2. That service needs to make a SOAP based call to a Sharepoint Web Service
  3. I need to consume that service
  4. I need to add additional pieces of information for my web service to the SOAP result (No problem here either)

The issue I have having is with point #2 and #3. I have found plenty of articles using WCF to consume SOAP based Web Services or using "Linq" to connect to sharepoint etc., but that's not what I'm looking for.

What I am looking for is simply a step by step process of what I need to do to push me in the right direction.

Example:

  1. add a web service reference??
  2. add this line(s) of code to create a new SOAP request??
  3. add this line(s) of code to parse and consume the service??

Thank you very much in advance!!!

Sample code would be greatly appreciated as well!


There's nothing magical about the fact that it's a web service. Just use "Add Service Reference" and then treat it like any other piece of code referencing a web service.

Also, are those who wrote the requirements aware that a WCF service can expose a basicHttpBinding endpoint that looks exactly like an ASMX web service endpoint? It would also have the benefit of all of the features of WCF, in addition to not using what Microsoft considers a "legacy technology".


The SharePoint Developer Center at MSDN would be a good place to refer to for general information, tutorials, etc. Server and Site Architecture: Object Model Overview in the Windows SharePoint Services 3 SDK would be a good place to start learning about the SharePoint object model, as the terms (SPSite, SPWeb, etc.) that you'll come across in examples can be confusing.

Basically you will want to add your web reference to the SharePoint web service that you intend to use. The specific reference that you use will depend on what you're trying to accomplish, there's a whole list of available Windows SharePoint Services Web Services. Those are for general SharePoint tasks such as interacting with lists and sites; there's also a whole separate set of web services for SharePoint Server which is what you would use for interacting with the Business Data Catalog, Enterprise Search, and any of the other features that come with SharePoint Server, not Windows SharePoint Services.

When you add the web reference in visual studio, it will automatically generate the proxy in your project against the remote web service and you use the generated proxy to do what you want to do. However, working directly against the web services, pretty much everything will return a generic XmlNode that you'll have to deal with, so if you're working in .NET, a much better alternative to using the web services directly would be to download the SharePoint SDK and program against the server object model.

If you do end up using the object model, make sure you read both of these thoroughly:
Best Practices: Common Coding Issues When Using the SharePoint Object Model
Best Practices: Using Disposable Windows SharePoint Services Objects


Here is small tutorial on what you're trying to do: http://www.xefteri.com/articles/show.cfm?id=15

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号