|
Creating Web Services with the Microsoft SOAP Toolkit, by Wei Meng Lee
WSJ Vol 01 Issue 00 - pg.15
Listing 1
Public Function searchBook(searchStr As String)
As String
Dim conn As New Connection
Dim rs As New Recordset
Dim connStr, sql, xmlStr As
String
Dim discount As Integer
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\InetPub\SOAPToolkit\Demo\Distributor.mdb;Persist Security Info=False"
conn.Open
connStr
sql = "SELECT
* FROM Books WHERE Title LIKE '%" & searchStr & "%'"
Set rs = conn.Execute(sql)
xmlStr = "<Result>"
While Not
rs.EOF
xmlStr = xmlStr & "<title>" & Trim(rs("Title")) & "</title>"
xmlStr = xmlStr & "<isbn>" & Trim(rs("ISBN")) & "</isbn>"
xmlStr = xmlStr & "<price>" & Trim(rs("Price")) & "</price>"
xmlStr = xmlStr & "<publisher>" & Trim(rs("Publisher"))
& "</publisher>"
rs.MoveNext
Wend
xmlStr = xmlStr
& "</Result>"
searchBook
= xmlStr
rs.Close
conn.Close
Set rs = Nothing
Set conn =
Nothing
End Function
Listing 2
<?xml version='1.0' encoding='UTF-16'
?>
<!-- Generated 02/11/01 by Microsoft
SOAP SDK WSDL File Generator, Version 1.0 -->
<definitions name ='BookStoreSystem'
targetNamespace = 'http://localhost/demo/BookStoreSystem.wsdl'
xmlns:tns='http://localhost/demo/BookStoreSystem.wsdl'
xmlns:xsd1='http://localhost/demo/BookStoreSystem.xsd'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<types>
<schema targetNamespace='http://localhost/demo/BookStoreSystem.xsd'
xmlns='http://www.w3.org/1999/XMLSchema'>
</schema>
</types>
<message name='searchBook'>
<part name='searchStr'
type='string'/>
</message>
<message name='searchBookResponse'>
<part name='searchStr'
type='string'/>
<part name='Result'
type='string'/>
</message>
<portType name='BookStoreSystemPortType'>
<operation name='searchBook'
parameterOrder='searchBookInOut1'>
<input
message='tns:searchBook' />
<output
message='tns:searchBookResponse' />
</operation>
</portType>
<binding name='BookStoreSystemBinding'
type='tns:BookStoreSystemPortType' >
<soap:binding style='document'
transport='http://schemas.xmlsoap.org/soap/http' />
<operation name='searchBook'
>
<soap:operation
soapAction='http://localhost/demo/bookstoresystem.asp' />
<input>
<soap:body use='encoded' namespace='http://localhost/demo/BookStoreSystem.xsd'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</input>
<output>
<soap:body use='encoded' namespace='http://localhost/demo/BookStoreSystem.xsd'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</output>
</operation>
</binding>
<service name='BookStoreSystem'
>
<port name='BookStoreSystemPortType'
binding='tns:BookStoreSystemBinding' >
<soap:address
location='http://localhost/demo/bookstoresystem.asp' />
</port>
</service>
</definitions>
Listing 3
<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:searchBookResponse
xmlns:m="http://localhost/demo/BookStoreSystem.xsd">
<searchStr>XML</searchStr>
<Result><Result><title>Professional
JSP : Using JavaServer Pages, Servlets, EJB, JNDI, JDBC, XML,
XSLT, and WML</title>
<isbn>1861003625</isbn>
<price>59.99</price>
<publisher>Wrox</publisher>
<title>Inside XML</title>
<isbn>0735710201</isbn>
<price>49.99</price>
<publisher>NewRiders</publisher>
<title>XML for the World Wide Web: Visual QuickStart Guide</title>
<isbn>0201710986</isbn>
<price>19.99</price>
<publisher>PeachPit</publisher>
</Result>
</Result>
</m:searchBookResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|