Partager via


Programming Directly to the Web Services

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Generally, agent mode programming is considered the best practice choice for remote access to the Commerce Server systems. However, if you have a good reason not to use the agent APIs, such as a requirement to access one or more of the relevant Commerce Server systems from a non-.NET environment, you can program directly to the Commerce Server Web services. Commerce Server lets you access the following Commerce Server systems through the Web services that those systems provide:

Using the Web service that is provided by a Commerce Server system is generally not as easy as using the equivalent agent API, in that sometimes several Web service calls are required to implement a single agent API method. Therefore, other rationales being equal, you should use the agent APIs when you need to interact with a Commerce Server system over the network. Examples of scenarios where programming directly to the Web services makes more sense than using the agent APIs include the following:

  • A system implemented in Java can use the Web services to integrate with Commerce Server.

  • A BizTalk application can use the Web services to retrieve Commerce Server data as part of an orchestration by using the BizTalk Web services adapter.

For more information about how to develop with the individual systems, see the following topics:

The rest of this topic summarizes how to create an instance of the various Commerce Server Web services so that you can access their methods over the network.

Using the Catalog Web Service

In order to use the Web services for the Commerce Server Catalog and Inventory Systems in the Microsoft Visual Studio 2005 or Visual Studio 2008 project, you must add a Web reference to the Catalog Web Service. By default, the URL for the Catalog Web Service is (where localhost may be another host name if you are accessing the Catalog Web Service over the network):

https://localhost/CatalogWebService/CatalogWebService.asmx

Assuming that you use a localhost URL as shown earlier, and that you have accepted the default string "localhost" as the Web reference name in the Visual Studio Add Web Reference dialog box, you would then use the following line of code to create an instance that is named "cws", of the CatalogWebService class through which you can access the various methods of the Catalog Web Service.

localhost.CatalogWebService cws = new localhost.CatalogWebService();

Note

Make sure that you include a using statement for the "System.Net" namespace. It may not be added by default when you create a project in Visual Studio.

Using the Marketing Web Service

In order to use the Web services for the Commerce Server Marketing System in your Visual Studio project, you must add a Web reference to the Marketing Web Service. By default, the URL for the Marketing Web Service is (where localhost may be another host name if you are accessing the Marketing Web Service over the network):

https://localhost/MarketingWebService/MarketingWebService.asmx

Assuming that you use a localhost URL as shown earlier, and that you have accepted the default string "localhost" as the Web reference name in the Visual Studio Add Web Reference dialog box, you would then use the following line of code to create an instance that is named "mws", of the MarketingWebService class through which you can access the various methods of the Marketing Web Service.

localhost.MarketingService mws = new localhost.MarketingService();

Note

Make sure that you include a using statement for the "System.Net" namespace. It may not be added by default when you create a project in Visual Studio.

For an example of using the marketing Web service, see Web Service Programming Sample.

Using the Orders Web Service

In order to use the Web services for the Commerce Server Orders System in your Visual Studio project, you must add a Web reference to the Orders Web Service. By default, the URL for the Orders Web Service is (where localhost may be another host name if you are accessing the Orders Web Service over the network):

https://localhost/OrdersWebService/OrdersWebService.asmx

Assuming that you use a localhost URL as shown earlier, and that you have accepted the default string "localhost" as the Web reference name in the Visual Studio Add Web Reference dialog box, you would then use the following line of code to create an instance that is named "ows", of the OrdersWebService class through which you can access the various methods of the Orders Web Service.

  localhost.OrderService ows = new localhost.OrderService();

Note

Make sure that you include a using statement for the "System.Net" namespace. It may not be added by default when you create a project in Visual Studio.

Using the Profiles Web Service

In order to use the Web services for the Commerce Server Profiles System in your Visual Studio project, you must add a Web reference to the Profiles Web Service. By default, the URL for the Profiles Web Service is (where localhost may be another host name if you are accessing the Profiles Web Service over the network):

https://localhost/ProfilesWebService/ProfilesWebService.asmx

Assuming that you use a localhost URL as shown earlier, and that you have accepted the default string "localhost" as the Web reference name in the Visual Studio Add Web Reference dialog box, you would then use the following line of code to create an instance that is named "pws", of the ProfilesWebService class through which you can access the various methods of the Profiles Web Service.

localhost.ProfilesWebService pws = new localhost.ProfilesWebService();

Note

Make sure that you include a using statement for the "System.Net" namespace. It may not be added by default when you create a project in Visual Studio.

See Also

Other Resources

Agent Mode Programming with the Management APIs

Local Mode Programming with the Management APIs

Web Service Programming Sample

Understanding the Different Types of Commerce Server APIs