Gengis
01 Apr 2005, 22:57
I do not know how many ppl here have used these two in conjunction, but I'm hoping someone has done something similar.
Basically what I am doing is exchanging data with other servers using xml. With each server having their own specific xml schema. The information is stored in our database which then has to be mapped to the xml elements in each schema. The way I'm going about this is using SQLXML. Below is an example of how I apply the mapping to the schema provided.
<?xml version='1.0' encoding='UTF-8' ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="contact" sql:relation="Contact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="contactName" sql:relation="Contact" sql:field="ContactName" type="xsd:string" />
<xsd:element name="contactGender" sql:relation="Contact" sql:field="ContactGender" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="contactId" sql:field="ContactID" sql:hide="true" type="xsd:integer" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
This is accessed using and xpath template, example below.
<root xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:header>
<sql:param name='ContactID'>0</sql:param>
</sql:header>
<sql:xpath-query mapping-schema="c:\inetpub\wwwroot\sqlxml\cdlTmp\schema\test_xsdma pping.xml">
/contact[@contactId=$ContactID]
</sql:xpath-query>
</root>
Up to this point everything is working as it should. I can access it like so:
http://servername/virtualDirectory/template/xpathQuery.xml?ContactID=1
And another method of accessing is so: (get to this later)
http://servername/virtualDirectory/schema/xsdSchema.xml/contact[@contactId=1]
It brings back the correct xml.
My theory was that seeming i can access the the xml via a URL, I can use MSXML to access the XML i require to post to the server. But behold, it doesn't work :/
This is brief code below of how I access it, using ASP (classic):
Dim objXmlHttp
Dim sXml
Set objXmlHttp = Server.CreateObject("Msxml2.XMLHTTP.4.0")
objXmlHttp.open "POST", "http://servername/virtualDirectory/template/xpathQuery.xml?ContactID=1", False
objXmlHttp.send()
sXml = Trim(objXmlHttp.responseText)
Using this I get the following error:
ERROR: 404 Not Found
HResult: 0x80070005
Source: Microsoft SQL isapi extension
Description: Access denied
If I change the URL parameter to the other option (http://servername/virtualDirectory/schema/xsdSchema.xml/contact[@contactId=1]) it works but this not the full result of the like the template xpath query.
So if anyone could help me with this, it would be much apprectiated.
Thanks in advance
Gen
PS. I think I have narrowed it down to some sort of setting to do with the Virtual Directory created. But my knowledge with this is very limited and has just lead to alot of frustration.
Basically what I am doing is exchanging data with other servers using xml. With each server having their own specific xml schema. The information is stored in our database which then has to be mapped to the xml elements in each schema. The way I'm going about this is using SQLXML. Below is an example of how I apply the mapping to the schema provided.
<?xml version='1.0' encoding='UTF-8' ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="contact" sql:relation="Contact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="contactName" sql:relation="Contact" sql:field="ContactName" type="xsd:string" />
<xsd:element name="contactGender" sql:relation="Contact" sql:field="ContactGender" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="contactId" sql:field="ContactID" sql:hide="true" type="xsd:integer" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
This is accessed using and xpath template, example below.
<root xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:header>
<sql:param name='ContactID'>0</sql:param>
</sql:header>
<sql:xpath-query mapping-schema="c:\inetpub\wwwroot\sqlxml\cdlTmp\schema\test_xsdma pping.xml">
/contact[@contactId=$ContactID]
</sql:xpath-query>
</root>
Up to this point everything is working as it should. I can access it like so:
http://servername/virtualDirectory/template/xpathQuery.xml?ContactID=1
And another method of accessing is so: (get to this later)
http://servername/virtualDirectory/schema/xsdSchema.xml/contact[@contactId=1]
It brings back the correct xml.
My theory was that seeming i can access the the xml via a URL, I can use MSXML to access the XML i require to post to the server. But behold, it doesn't work :/
This is brief code below of how I access it, using ASP (classic):
Dim objXmlHttp
Dim sXml
Set objXmlHttp = Server.CreateObject("Msxml2.XMLHTTP.4.0")
objXmlHttp.open "POST", "http://servername/virtualDirectory/template/xpathQuery.xml?ContactID=1", False
objXmlHttp.send()
sXml = Trim(objXmlHttp.responseText)
Using this I get the following error:
ERROR: 404 Not Found
HResult: 0x80070005
Source: Microsoft SQL isapi extension
Description: Access denied
If I change the URL parameter to the other option (http://servername/virtualDirectory/schema/xsdSchema.xml/contact[@contactId=1]) it works but this not the full result of the like the template xpath query.
So if anyone could help me with this, it would be much apprectiated.
Thanks in advance
Gen
PS. I think I have narrowed it down to some sort of setting to do with the Virtual Directory created. But my knowledge with this is very limited and has just lead to alot of frustration.