4.4 Exception Handling

If a fault occurs, the protocol server sends a SOAP fault message to notify the protocol client. As an example, if the protocol client tries to create a crawl rule with a path that already exists, the protocol server returns a SOAP fault message reporting the problem. The following messages illustrate this scenario.

Request message:

 <s:Envelope 
   xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:a="http://www.w3.org/2005/08/addressing" 
   xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
     <a:Action s:mustUnderstand="1">
       http://tempuri.org/ISearchApplicationAdminWebService/AddAdvancedCrawlRule
     </a:Action>
     <a:MessageID>
       urn:uuid:aa215fdb-e07a-40ce-9a57-2a1386d02279
     </a:MessageID>
     <a:ReplyTo>
       <a:Address>
         http://www.w3.org/2005/08/addressing/anonymous
       </a:Address>
     </a:ReplyTo>
     <ServiceContext 
       xmlns="http://schemas.microsoft.com/sharepoint/servicecontext" 
       xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
       <correlationId>
         b1c3e066-a1e5-41eb-8ed7-da68a8f36f4a
       </correlationId>
       <language>en-US</language>
       <region>en-US</region>
       <siteSubscriptionId>
         00000000-0000-0000-0000-000000000000
       </siteSubscriptionId>
     </ServiceContext>
     <a:To s:mustUnderstand="1" u:Id="_1">
       https://example.com:32844/0058e686f6ab4d9f8cea639340ab947c/SearchAdmin.svc
     </a:To>
   </s:Header>
   <s:Body>
     <AddAdvancedCrawlRule xmlns="http://tempuri.org/">
       <versionIn>4</versionIn>
       <currentUser>DOMAINNAME\username</currentUser>
       <isIncludeRule>false</isIncludeRule>
       <isAdvancedRegularExpression>false</isAdvancedRegularExpression>
       <caseSensitiveUR>false</caseSensitiveUR>
       <path>http://example.com/*</path>
     </AddAdvancedCrawlRule>
   </s:Body>
 </s:Envelope>

Response message:

 <s:Envelope
   xmlns:s="http://www.w3.org/2003/05/soap-envelope"
   xmlns:a="http://www.w3.org/2005/08/addressing"
   xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
     <a:Action s:mustUnderstand="1">
       http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault
     </a:Action>
     <a:RelatesTo>
       urn:uuid:aa215fdb-e07a-40ce-9a57-2a1386d02279
     </a:RelatesTo>
   </s:Header>
   <s:Body>
     <s:Fault>
       <s:Code>
         <s:Value>s:Receiver</s:Value>
         <s:Subcode>
           <s:Value
             xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">
             a:InternalServiceFault
           </s:Value>
         </s:Subcode>
       </s:Code>
       <s:Reason>
         <s:Text xml:lang="en-US">
           The object you are trying to create already exists. Try again using a different name.
         </s:Text>
       </s:Reason>
       <s:Detail>
         <ExceptionDetail
           xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel"
           xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
           <HelpLink i:nil="true"></HelpLink>
           <InnerException i:nil="true"></InnerException>
           <Message>
             The object you are trying to create already exists. Try again using a different name.
           </Message>
           <StackTrace>
             at Microsoft.Office.Server.Search.Administration.SearchApi.RunOnServer[T](CodeToRun`1 remoteCode, CodeToRun`1 localCode, Boolean useCurrentSecurityContext, Int32 versionIn)at Microsoft.Office.Server.Search.Administration.SearchApi.RunOnServer[T](CodeToRun`1 remoteCode, CodeToRun`1 localCode)at Microsoft.Office.Server.Search.Admi An error occurred while parsing EntityName. Line 39, position 901nistration.SearchApi.AddCrawlRule(Int32 versionIn, String currentUser, Boolean isIncludeRule, Boolean isAdvancedRegularExpression, Boolean caseSensitiveURL, String path)at Microsoft.Office.Server.Search.Administration.SearchAdminWebServiceApplication.AddAdvancedCrawlRule(Int32 versionIn, String currentUser, Boolean isIncludeRule, Boolean isAdvancedRegularExpression, Boolean caseSensitiveURL, String path)at SyncInvokeAddAdvancedCrawlRule(Object , Object[], Object[])at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[]inputs, Object[]&outputs)at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&rpc)at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
           </StackTrace>
           <Type>System.Runtime.InteropServices.COMException</Type>
         </ExceptionDetail>
       </s:Detail>
     </s:Fault>
   </s:Body>
 </s:Envelope>