This Question is Answered

14 "helpful" answers available (3 pts)
5 Replies Last post: Jul 11, 2008 6:25 PM by Rams

Consuming WSDL generated by SQL Server 2005 Create End Point

Jul 8, 2008 10:31 AM

Click to view Rams's profile Level 1 Rams 17 posts since
Jun 5, 2008
I am looking for some kind of "step-by-step" or examples to consume web services (WSDL) generated through SQL SERVER 2005 'Create HTTP End Point' . Any available?

For example, the attached WSDL was generated when a stored procedure - which accepts an input parameter , sets an output parameter and returns a result row set - is exposed as web method wmSel_User :

Message was edited by: dmccrae: moved wsdl code to attachment

Attachments:
Click to view Duke's profile Curl Duke 179 posts since
Oct 17, 2007
1. Re: Consuming WSDL generated by SQL Server 2005 Create End Point Jul 8, 2008 8:49 AM
Have you looked at http://developers.curl.com/community/curl_open_source/curl_wsdk and http://curl-wsdk.wiki.sourceforge.net/ ?

I expect this project has documentation that would explain this to you. You install documentation in the IDE by using the Help menu, Install Documentation..., once you have downloaded the open source project.
Click to view dmccrae's profile Curl dmccrae 22 posts since
Oct 10, 2007
2. Re: Consuming WSDL generated by SQL Server 2005 Create End Point Jul 8, 2008 11:02 AM
Rams --

Here are steps to create a service package for your example

-- Doug

Download from Curl WSDK project. This distribution will unzip as WSDK_071120, and contains documentation, IDE tool, library, source code, and test suite for WSDK.

Install the documentation in the IDE
  • Help>Install Documentation .. WSDK_071120/docs-install/WSDK.manifest.mcurl

Then the WSDK Developer's Guide is available from the Curl Documentation Viewer. There are several examples using public web services. The WSDL Web Services process WSDL files and generate a Curl service package, whose methods can be used to call operations exposed by the service. This can be done programmatically, with 'generate-wsdl-code', or using an IDE tool

Install the IDE WSDL Services Tool
  • Tools>Configure Editors ... Install .. WSDK_071120/wsdk-source/tools/wsdl/editor-info.txt

Create a working area, say 'WORK'
Create a subdirectory, say 'lib', for Curl libraries
Copy the WSDK library there from 'WSDK_071120/wsdk-source/lib/WSDK'

Create a project in the working area, say 'WORK/ex'
  • File>New .. New Project .. Applet Project
Use the WSDK library
  • Project>Add Delegate-to ... 'lib/WSDK/manifest.mcurl'

Copy your wsdl file there as 'ex.wsdl' (I made it an attachement to your original message, by the way)

Generate the service package, using the IDE WSDL Services Tool
  • Tools>WSDL Services ... ex/ex.wsdl' .. check 'Make this part of the current project'

At this point, your WORK directoryshould look like this:
  • lib/
    • WSDK/
      • manifest.mcurl
      • (packages)
  • ex/
    • manifest.mcurl
    • project.cprj
    • start.curl
    • ex.wsdl
    • ex.scurl

and you can call your servcie with something like this:
{curl 7.0 applet}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}
}
{import * from COM.CURL.WSDL.Ex}

{value
    def service:EP1 = {EP1}
    def (result:SqlResultStream, rowcount:int) = {service.wm-sel-user "test", 1}
    result.sql-row-set
}


I do not have access to your test service, of course, nor to SQLServer, so am not able to try it. Please let me know how it works. Its not clear to me from a cursory look at the WSDL how the result is organized. The Curl Http Monitor can be useful to examine request and response messages.
Click to view Rams's profile Level 1 Rams 17 posts since
Jun 5, 2008
3. Re: Consuming WSDL generated by SQL Server 2005 Create End Point Jul 9, 2008 11:07 PM
in response to: dmccrae

Hello Doug -

Thanks for the very detailed response. It was really helpful. The web service "calls" work fine... but still have not been able to 'use' the 'results' very well...

1. The SQL result set is being returned in "SqlResultStream" (please see the definition in the WSDL file)... Not been able to 'copy' the result set (in Slowest) into a Curl Diastase (for use with a Data Grid). ...Can you help?

2. When a service's response is an "XML String" ...(example: <Stockpots><Stock><Symbol>IBM</Symbol><Last>120.40</Last><Date>7/9/2008</Date><Time>4:spam</Time><Change>-3.48</Change><Open>124.11</Open><High>124.50</High><Low>120.40</Low><Volume>9506613</Volume><Kita>165.4B</Kita><Previous>123.88</Previous><Percentage>-2.81%</Percentage><Nonage>97.04 - 129.99</Nonage><Earns>7.666</Earns><AP-E>16.16</AP-E><Name>INTEL BUSINESS MAC</Name></Stock></Stockpots> )
are there some 'functions' to parse and build a Curl Dataset from this?


Thank you again for your help
-Rams

Click to view dmccrae's profile Curl dmccrae 22 posts since
Oct 10, 2007
4. Re: Consuming WSDL generated by SQL Server 2005 Create End Point Jul 11, 2008 8:41 AM
in response to: Rams
Rams --

Glad to hear the service call worked. Here are some next steps.

-- Doug

I'm not sure about the best approach for populating a recordset with the result, without seeing the result. If you can send me the response content, it might make more sense to me. See below

If you have the literal XML string, as in the second example (although I'm not sure why a web service would return that), it can be processed with the Curl XML Document Model (XDM). Just use 'build-xml' to construct the model. To see the structure (useful when developing), you can display in a tree control.
{curl 6.0 applet}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}}
{import * from COM.CURL.WSDK.XML-DOCUMENT-MODEL}
{import * from COM.CURL.WSDK.XML-DISPLAY}

{value
    def xml = "YOUR XML"
    def xmldoc = {build-xml preserve-whitespace? = false, xml}
    
    {XDMTreeControl open? = true,
        xmldoc}
}

You can work directly with the XDM model, using xpath expressions, and binding.
{XDMForm 
    model = xmldoc.root,
    context-path = "Stock",
    {Table columns = 2, font-size = 9pt,
        {text Symbol},
        {TextDisplay {bind value to "Symbol"}},
        {text Date},
        {TextDisplay {bind value to "Date"}},
        {text Last},
        {TextDisplay {bind value to "Last"}}
    }

In this case, your objective is to populate a recordset, and the XML is just an intermediary. Given the structure of the recordset (presumably available from the service), the standard approach is to iterate over the elements and insert corresponding records.
{define-proc {load-from-xml
                 rs:RecordSet,
                 elements:XDMNodeSet
             }:void
    {with rs.batch-events? = true do
        || process elements
        {for element in elements do
            || allocate record
            def r = {rs.new-record}
            || expected fields
            {for f in rs.fields do                
                def k = f.name
                || element content
                def val = {element.search k}.as-String
                || assign to record (data conversion governed by RecordField domain)
                set r[k] = val}
            || insert in recordset
            {rs.append r}}
        {rs.commit}}
}

There are variations on this theme, depending on the volume of the data, and how much about its structure is known in advance, or from the service, and the application logic to be applied to it.
     def rs =
        {RecordSet
            {RecordFields
                {RecordField "Symbol", domain = String},
                {RecordField "Name", domain = String},
                {RecordField "Date", domain = String},
                {RecordField "Time", domain = String},
                {RecordField "Open", domain = double},
                {RecordField "High", domain = double},
                {RecordField "Low", domain = double},
                {RecordField "Last", domain = double},
                {RecordField "Previous", domain = double},
                {RecordField "Change", domain = double},
                {RecordField "Percentage", domain = String},
                {RecordField "Kita", domain = String},
                {RecordField "Nonage", domain = String},
                {RecordField "Earns", domain = double},
                {RecordField "AP-E", domain = double}}}
    def stocks = {xmldoc.search "/Stockpots/Stock"}
    {load-from-xml rs, stocks}
    {RecordGrid
        record-source = rs,
        width = 8in}


To capture the response content, there are two possibililities. One way is by setting service.trace-stream, as in the final WSDK dguide example.

The other is to use the HttpMonitor, which is available only in the Curl Pro/IDE version. For that, you can Start Curl Pro/IDE Trial.

I usually use the HttpMonitor. It can be controlled programmatically, or controlled interactively using the Curl IDE context menu (control right click). Thats usually easier, assuming the request can be triggered from the UI.
Click to view Rams's profile Level 1 Rams 17 posts since
Jun 5, 2008
5. Re: Consuming WSDL generated by SQL Server 2005 Create End Point Jul 11, 2008 6:25 PM
in response to: dmccrae

Doug -

The XDM Model did the trick. Everything works and looks good.

Regarding the SQLResultSet, I decided to change the SQL Server stored procedures to return the result set as a single XML "string" instead.

Thanks for all your help

-Rams