Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Service Broker / September 2008

Tip: Looking for answers? Try searching our database.

Service Broker XML Validation?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
newscorrespondent@charter.net - 11 Sep 2008 20:35 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.