Download
Cover
Contents
Milestone One
Milestone Two
Milestone Three
Appendix
Diary
Biblography
Code Samples
background image
Previous
04029437
m1.54
2.8.1.1 Microsoft's SOAP spellchecking
In section 2.6.2 we discussed SOAP and used the Microsoft Live Search Web-Service API
as an example. One of the elements within the SOAP request allows us to specify the
source from which the results set originates. One of those sources is
Spelling
[MS07].
The
Spelling
source provides spelling suggestions. Let's modify the SOAP message in
Code Sample 26 to invoke the Web-Service and search for spelling suggestions for the
word
Mistaek
:
Code Sample 44
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://schemas.microsoft.com/MSNSearch/2005/09/fex" >
<soap:Body>
<tns:Search>
<tns:Request>
<tns:AppID>FE82032631F9C2A5C058C2F5FD6704E00303E461</tns:AppID>
<tns:Query>Mistaek</tns:Query>
<tns:CultureInfo>en-gb</tns:CultureInfo>
<tns:SafeSearch>Moderate</tns:SafeSearch>
<tns:Flags>None</tns:Flags>
<tns:Requests>
<tns:SourceRequest>
<tns:Source>Spelling</tns:Source>
<tns:Offset>0</tns:Offset>
<tns:Count>1</tns:Count>
<tns:SortBy>Default</tns:SortBy>
<tns:ResultFields>Title</tns:ResultFields>
</tns:SourceRequest>
</tns:Requests>
</tns:Request>
</tns:Search>
</soap:Body>
</soap:Envelope>
Apart from the query, only two values have changed; the
Source
and the
ResultFields
.
Source
now tells the Web-Service that we want spelling suggestions, not web search
results.
ResultFields
now only requests the
Title
element be returned for the results,
this is because spelling suggestions from this API only offer the
Title
element.
Now we can examine the response:
Code Sample 45
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<SearchResponse
xmlns="http://schemas.microsoft.com/MSNSearch/2005/09/fex">
<Response>
<Responses>
<SourceResponse>
<Source>Spelling</Source>
<Offset>0</Offset>
<Total>1</Total>
<Results>
<Result>
<Title>Mistake</Title>
</Result>
</Results>
</SourceResponse>
</Responses>
</Response>
</SearchResponse>
</soapenv:Body>
</soapenv:Envelope>
Navigation