The error message I get when sending a message
Conversion failed when converting the nvarchar value 'A message of type
'SQLServerSourceControlSubversionRequest'
failed XML validation on the target service.
XML Validation: Declaration not found for element
'SubversionMessageRequest'.
Location: /*:SubversionMessageRequest[1]
This occurred in the message with Conversation ID
'4D8953BF-2F94-46A8-8AE3-0DEE68DA1429',
Initiator: 1, and Message sequence number: 0.' to data type int.'
Needless to say my XML is almost not existant. So here is what I have
defined.
CREATE XML SCHEMA COLLECTION dbo.SQLServerSourceControlSchemCollection AS N'
<xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1"
xmlns:schema="urn:schemas-microsoft-com:sql:SqlRowSet1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
elementFormDefault="qualified">
<xsd:import
namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd"
/>
<xsd:element name="SubversionMessageRequest">
<xsd:complexType>
<xsd:attribute name="EventID" type="sqltypes:int" use="required" />
<xsd:attribute name="EventType" type="sqltypes:nvarchar"
use="required">
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1"
xmlns:schema="urn:schemas-microsoft-com:sql:SqlRowSet1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
elementFormDefault="qualified">
<xsd:import
namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd"
/>
<xsd:element name="SubversionMessageResponse">
<xsd:complexType>
<xsd:attribute name="ResponseID" type="sqltypes:int" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
'
GO
CREATE MESSAGE TYPE SQLServerSourceControlSubversionRequest
VALIDATION = VALID_XML WITH SCHEMA COLLECTION
SQLServerSourceControlSchemCollection;
GO
CREATE MESSAGE TYPE SQLServerSourceControlSubversionResponse
VALIDATION = VALID_XML WITH SCHEMA COLLECTION
SQLServerSourceControlSchemCollection;
GO
CREATE CONTRACT SQLServerSourceControlSubversionContract
( SQLServerSourceControlSubversionRequest SENT BY INITIATOR
,SQLServerSourceControlSubversionResponse SENT BY TARGET
);
GO
This is the message string constructed
<SubversionMessageRequest><EventID>1</EventID><EventType>http://schemas.microsoft.com/SQL/Notifications/EventNotification</EventType></Su
bversionMessageRequest>
This is what I am using to send the message
BEGIN DIALOG CONVERSATION @ConversationHandle
FROM SERVICE SQLServerEventLoggingService
TO SERVICE 'SQLServerSourceControlSubversionService'
ON CONTRACT SQLServerSourceControlSubversionContract
WITH ENCRYPTION = OFF;
SEND ON CONVERSATION @ConversationHandle
MESSAGE TYPE SQLServerSourceControlSubversionRequest
(@SubversionMessage);
My guess is that I am not putting enough infomration in the XML for the
broker to find the validation schema in SQL server
but I am not sure what or how I need to add to the XML.
Thanks
Tom
Dan Guzman - 12 Sep 2008 12:30 GMT
> My guess is that I am not putting enough infomration in the XML for the
> broker to find the validation schema in SQL server
> but I am not sure what or how I need to add to the XML.
You are correct that there is not enough info in the XML. The namespace
needs to be specified. One method:
<SubversionMessageRequest
xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1"><EventID>1</EventID><EventType>http://schemas.microsoft.com/SQL/Notifications/EventNotification</EventType></Su
bversionMessageRequest>
Once the namespace is specified, you will find that the XML still fails
validation because the schema expects attributes instead of elements for
EventID and EventType. The following example is valid against your schema:
<SubversionMessageRequest xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1"
EventID="1"
EventType="http://schemas.microsoft.com/SQL/Notifications/EventNotification"></SubversionMe
ssageRequest>

Signature
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
> The error message I get when sending a message
>
[quoted text clipped - 85 lines]
> Thanks
> Tom