SharePoint search service returns SERVER_ERROR (SQ

2019-06-10 08:39发布

问题:

I have a simple WCF webservice client that sends a request to Microsoft Search Server (included with SharePoint 2007) on /more/_vti_bin/search.asmx

The request is sent

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Query xmlns="urn:Microsoft.Search">
<queryXml>&lt;QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000"&gt; &lt;Query&gt; &lt;Context&gt; &lt;QueryText language="fr-FR" type="STRING"&gt;foo bar&lt;/QueryText&gt;&lt;/Context&gt; &lt;/Query&gt; &lt;/QueryPacket&gt; </queryXml>
</Query></s:Body></s:Envelope>

But the response shows a SQLException error

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<QueryResponse xmlns="urn:Microsoft.Search">
<QueryResult>&lt;ResponsePacket xmlns="urn:Microsoft.Search.Response"&gt;&lt;Response domain=""&gt;&lt;Status&gt;ERROR_SERVER&lt;/Status&gt;&lt;DebugErrorMessage&gt;System.Data.SqlClient.SqlException&lt;/DebugErrorMessage&gt;&lt;/Response&gt;&lt;/ResponsePacket&gt;</QueryResult>
</QueryResponse></soap:Body></soap:Envelope>

回答1:

It states there's been a sql exception, coulld you check on your sql machine if any errors occurred?



回答2:

there is a problem with your request. test your search service using this tool



回答3:

After some further analysis, I have understood that the problem lies in the fact that the Soap query does not start with an XML declaration.

<?xml version="1.0">

This is perfectly possible and respectful of standards but SharePoint doesn't like that.

The question becomes: How to force the WCF client to starts with an XML declaration.