DiffGram to Update SQL 2000 DB with WebServices Data Adapter (SOAP)

G

Guest

Everything works correctly; however, the table in the SQL 2000 database does not change
What is the first parameter in the SOAP [WebMethod] Update method suppose to be? Is it suppose to be the DiffGram

What works
I have a WebService that was generated with Visual Studio.Net as per a Microsoft C# Walk Through. It works
The Web Service accesses the SQL Server 2000 by using the data adapter that was created by Visual Studio.NET. I can use the Web Service client C# program to access the table and it will display the table to the Internet Explore browser. Furthermore, I can update the table that is in the database. This is done with the HTTP POST method.

I want to use the SOAP access method and I need to access the Web Service via a C++ client program. I used Visual Studio.Net C++ to create a Web Service Client program. The program can access the Web Service [WebMethod] for the Get Data method. It returns an XML description of the single table that is bound to the data adapter. This works correctly and there are no problems. The XML correctly represents the table in my Data Base. In addition, it also has the diffgram sections included

When the same program accesses the [WebMethod] for the Update Data it returns a response that would indicate that there are no errors and that everything worked correctly

What does not work
When I look at the table in the SQL 2000 database, it has not changed. The Updata data [WebMethod] requires two parameters, the first parameter is the changes and the second parameter is the pointer to the BSTR that is to receive the response. I am guessing that the first parameter is suppose to be the diffgram.

I do not know what the first parameter needs to be so that the system will update the SQL 2000 table in the database

I have included the program snippets and the XML of the database

void AccessService()
using namespace std
XXXXXXXService::CXXXXXXXService ws
//GetXXXXXXXs GetXXXXXXXs GetXXXXXXXs GetXXXXXXXs GetXXXXXXXs GetXXXXXXXs GetXXXXXXXs
BSTR bstrBuffer = SysAllocString(L"bstrBuffer to receive the GetXXXXXXXs XML string")
BSTR * pbstrBuffer = &bstrBuffer
HRESULT hrget = ws.GetXXXXXXXs(pbstrBuffer);
if(SUCCEEDED(hrget))
// The XML that was received for this ws.GetXXXXXXs is shown below
cout << "\nSuccessful conversion of ws.GetXXXXXXXs(pBuffer)\n"

else
cout << "\nGot an error in ws.GetXXXXXXXs(pBuffer)\n"


// UpDateXXXXXXXsUpDateXXXXXXXsUpDateXXXXXXXsUpDateXXXXXXXsUpDateXXXXXXXsUpDateXXXXXXX
BSTR bstrChangedBuffer = SysAllocString(L"bstrChangedBuffer to receive the UpDateXXXXXXXs XML string")
BSTR * pbstrChangedBuffer = &bstrChangedBuffer

BSTR bstrDiffGramBuffer = SysAllocString(L"bstrDiffGramBuffer to send to UpDateXXXXXXXs")
bstrDiffGramBuffer = ::SysAllocStringLen(NULL, 10000);// Memory allocation
Note: The following XML has has been modified with new lines for easier reading of this document
char MultibyteDiffGramBuffer[10000] =
"<diffgr:diffgram xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" xmlns:diffgr=\"urn:schemas- microsoft-com:xml-diffgram-v1\"><XXXXXXX1 xmlns=\"\"><ReportOfCallerInput diffgr:id=\"ReportOfCallerInput2\" data:rowOrder=\"1" diffgr:hasChanges=\"modified\"><Command>NewValueToBeWrittenIntoSQL2000DataBase</Command></ReportOfCallerInput></XXXXXXX1><diffgr:before><ReportOfCallerInput diffgr:id=\"ReportOfCallerInput2\" msdata:rowOrder=\"1\" xmls=\"\"><Command>OldValueThatNeedsToBeModified</Command></ReportOfCallerInput></diffgr:before></diffgr:diffgram>"

// Here we convert the MultibyteBuffer to BSTR bstrDiffGramBuffe
MultiByteToWideChar(CP_ACP, //ANSI code pag
0, // character-type option
MultibyteDiffGramBuffer, // string to ma
-1, //automatic calculation of number of bytes in strin
bstrDiffGramBuffer, // wide-character buffer
9900 ); // size of buffer

HRESULT hrupdate = ws.UpDateXXXXXXXs(bstrDiffGramBuffer, pbstrChangedBuffer);
if(SUCCEEDED(hrupdate)) {
cout << "\nWe succeeded with ws.UpDateXXXXXXXs(bstrDiffGramBuffer, bstrChangedBuffer)\n";
}
else {
cout << "\nGot an error in ws.UpDateXXXXXXXs(bstrDiffGramBuffer, bstrChangedBuffer)\n";
}
}


THIS IS THE XML THAT WAS RETURNED WITH THE GET REQUEST, IT REPRESENTS THE DATA SET. ReportOfCallerInput

<xs:schema id="XXXXXX1" targetNamespace="http://www.tempuri.org/XXXXXX1.xsd" xmlns:mstns="http://www.tempuri.org/XXXXXX1.xsd" xmlns="http://www.tempuri.org/XXXXXX1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="XXXXXX1" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="ReportOfCallerInput"><xs:complexType><xs:sequence><xs:element name="LineNumber" type="xs:string"></xs:element><xs:element name="Command" type="xs:string" minOccurs="0"></xs:element><xs:element name="Tag" type="xs:string" minOccurs="0"></xs:element><xs:element name="Response" type="xs:string" minOccurs="0"></xs:element><xs:element name="Parameters" type="xs:string" minOccurs="0"></xs:element></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="Constraint1" msdata:primaryKey="true"><xs:selector xpath=".//mstns:ReportOfCallerInput"></xs:selector><xs:field xpath="mstns:LineNumber"></xs:field></xs:unique></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><XXXXXX1 xmlns="http://www.tempuri.org/XXXXXX1.xsd"><ReportOfCallerInput diffgr:id="ReportOfCallerInput1" msdata:rowOrder="0"><LineNumber>0001</LineNumber><Command>JUSTPLAY</Command><Tag>00010</Tag><Response>1</Response><Parameters>THIS IS LINE ONE updated at 11:48 AM on Friday</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1"><LineNumber>0002</LineNumber><Command>CONFIRM</Command><Tag>00020</Tag><Response>2</Response><Parameters>LINE TWO IS HERE</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput3" msdata:rowOrder="2"><LineNumber>0003</LineNumber><Command>TRANSFER</Command><Tag>00034</Tag><Response>3</Response><Parameters>LINE 3 IS TRANSFERED</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput4" msdata:rowOrder="3"><LineNumber>0004</LineNumber><Command>8888888888888888888</Command><Tag>77777</Tag><Response>4</Response><Parameters>LINE FOUR CALLING</Parameters></ReportOfCallerInput></XXXXXX1></diffgr:diffgram>
 
G

Guest

This is an update to my previous request.

These are the XML files that were transmitted and received from the WebService.
First, I performed the get functions and received the xml for the data set, next I sent a diffgram, and received a response.
I then used the information in the response to submit a schema in addition to the diffgram, it returned the same response.
The data in the SQL Server 2000 database was not changed.

FIRST I PERFORMED A GET AND RECEIVED THIS XML WHICH HAS THE SCHEMA THAT

<xs:schema id="Voice1" targetNamespace="http://www.tempuri.org/Voice1.xsd" xmlns:mstns="http://www.tempuri.org/Voice1.xsd" xmlns="http://www.tempuri.org/Voice1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="Voice1" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="ReportOfCallerInput"><xs:complexType><xs:sequence><xs:element name="LineNumber" type="xs:string"></xs:element><xs:element name="Command" type="xs:string" minOccurs="0"></xs:element><xs:element name="Tag" type="xs:string" minOccurs="0"></xs:element><xs:element name="Response" type="xs:string" minOccurs="0"></xs:element><xs:element name="Parameters" type="xs:string" minOccurs="0"></xs:element></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="Constraint1" msdata:primaryKey="true"><xs:selector xpath=".//mstns:ReportOfCallerInput"></xs:selector><xs:field xpath="mstns:LineNumber"></xs:field></xs:unique></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><Voice1 xmlns="http://www.tempuri.org/Voice1.xsd"><ReportOfCallerInput diffgr:id="ReportOfCallerInput1" msdata:rowOrder="0"><LineNumber>0001</LineNumber><Command>JUSTPLAY</Command><Tag>00010</Tag><Response>1</Response><Parameters>THIS IS LINE ONE updated at 11:48 AM on Friday</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1"><LineNumber>0002</LineNumber><Command>CONFIRM</Command><Tag>00020</Tag><Response>2</Response><Parameters>LINE TWO IS HERE</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput3" msdata:rowOrder="2"><LineNumber>0003</LineNumber><Command>TRANSFER</Command><Tag>00034</Tag><Response>3</Response><Parameters>LINE 3 IS TRANSFERED</Parameters></ReportOfCallerInput><ReportOfCallerInput diffgr:id="ReportOfCallerInput4" msdata:rowOrder="3"><LineNumber>0004</LineNumber><Command>88888888</Command><Tag>77777</Tag><Response>4</Response><Parameters>LINE FOUR CALLING</Parameters></ReportOfCallerInput></Voice1></diffgr:diffgram>




THE .NET Framework Developer's Guide for DiffGrams is at this web page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondiffgrams.asp
Using that as the template then:

I SEND AN UPDATE REQUEST AND USED THIS DIFFGRAM:



<?xml version="1.0"?><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Voice1 ><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1" diffgr:hasChanges="modified"><Command>MyDiffGram</Command></ReportOfCallerInput></Voice1><diffgr:before><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1" xmls=""><Command>CONFIRM</Command></ReportOfCallerInput></diffgr:before><diffgr:errors></diffgr:errors></diffgr:diffgram>


THE WEB SERVICE RETURNED THIS XML


<xs:schema id="voiceChanges" targetNamespace="http://tempuri.org/" xmlns:mstns="http://tempuri.org/" xmlns="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="voiceChanges" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"></diffgr:diffgram>


USING THIS REPLY AS A HINT, I MODIFIED MY DIFFGRAM TO INCLUDE SCHEMA INFORMATION
AND THEN SENT IT. THIS IS THE DIFFGRAM:

<?xml version="1.0"?><xs:schema id="voiceChanges" targetNamespace="http://tempuri.org/" xmlns:mstns="http://tempuri.org/" xmlns="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="voiceChanges" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Voice1 ><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1" diffgr:hasChanges="modified"><Command>MyDiffGram</Command></ReportOfCallerInput></Voice1><diffgr:before><ReportOfCallerInput diffgr:id="ReportOfCallerInput2" msdata:rowOrder="1" xmls=""><Command>CONFIRM</Command></ReportOfCallerInput></diffgr:before><diffgr:errors></diffgr:errors></diffgr:diffgram>


THE RESPONSE TO THIS NEW DIFFGRAM IS IDENTICAL TO THE PREVIOUS RESPONSE.

I CONTINUED TO RECEIVE THE SAME RESPONSE, WHEN I SEND ANY DIFFGRAM.
FOR EXAMPLE, I GOT THE SAME RESPONSE WHEN I SENT THIS DIFFGRAM:

<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><diffgr:errors></diffgr:errors></diffgr:diffgram>

IS THERE A PROBLEM WITH THE "ADD WEB REFERENCE" FOR C++ IN THE VISUAL STUDIO.NET PROGRAM.

THANKS,
AUSTIN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top