473,770 Members | 6,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using data with an xsd to send a string of xml to a web service

I know I wrote before a week ago when I knew even less than now but I am
getting better please anyone give me a clue or an example. Am I completely
off track?
I have a datarow in a table with the fields to map to an xsd. Then i call a
web service upload method that wants the xml strongly typed to the xsd in a
string.

so I have generated a class from a xsd newcust.cs in .net 1.1 c#
to start with just to see what it means to use an xsd with a dataset to
create an xml document for starter but I get the error at the end I know I
am new but I am running out of options to teach myself from examples online.

using System;
using System.Xml;
using System.Xml.Seri alization;
using System.IO;
namespace xmlsenddata
{
[XmlRootAttribut e("PurchaseOrde r", Namespace="",Is Nullable = true)]

public class newcust
{
public DOCUMENT xdoc;
public DOCUMENTDOCUMEN THEADER xhdr;
public DOCUMENTCustome r xcust;
}

public class DOCUMENT
{
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public DOCUMENTDOCUMEN THEADER DOCUMENTHEADER;
[System.Xml.Seri alization.XmlEl ementAttribute( "Customer",
Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public DOCUMENTCustome r[] Customer;
}
public class DOCUMENTDOCUMEN THEADER
{
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string SENDER;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string RECIPIENT;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string TYPE;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string SUBTYPE;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string REFERENCENO;
}

public class DOCUMENTCustome r
{
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string AccountNumber;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string Address1;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string City;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string State;
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public string Zip;
}
}

I have a web page that gets a data set and I try to use the data to
serialize an XML doc using the class newcust.

public class WebForm2 : System.Web.UI.P age
{
string connString = "Data Source=tsbusisd ev; Initial Catalog=pubs;
Integrated Security=SSPI";
string sqlQueryString = "";
public newcust nc = new newcust();
private void Page_Load(objec t sender, System.EventArg s e)
{
newcustomer();
}

private void newcustomer()
{
sqlQueryString = "Select * from authors where au_id = '172-32-1176'";
SqlConnection myConn = new SqlConnection(c onnString);
SqlDataAdapter adapter = new SqlDataAdapter( );
adapter.SelectC ommand = new SqlCommand(sqlQ ueryString,myCo nn);
DataSet myDs = new DataSet();
adapter.Fill(my Ds);
XmlSerializer serializer = new XmlSerializer(t ypeof(newcust)) ;
TextWriter writer = new StreamWriter("c :\\docnc.xml");
//Create header
nc.xhdr.RECIPIE NT = "GEW_EASINE T";
nc.xhdr.TYPE = "ESP_CUSTOM ER";
nc.xhdr.SENDER = "GEW_WEB";
nc.xhdr.SUBTYPE ="NEW-GEW";
nc.xhdr.REFEREN CENO=myDs.Table s[0].Rows[0]["au_id"].ToString();
//create cust
nc.xcust.Accoun tNumber = myDs.Tables[0].Rows[0]["contract"].ToString();
nc.xcust.Addres s1 = myDs.Tables[0].Rows[0]["address"].ToString();
nc.xcust.City = myDs.Tables[0].Rows[0]["city"].ToString();
nc.xcust.State = myDs.Tables[0].Rows[0]["state"].ToString();
nc.xcust.Zip = myDs.Tables[0].Rows[0]["zip"].ToString();
//write file
serializer.Seri alize(writer, nc);
writer.Close();

}
I get an error

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:
Line 39: TextWriter writer = new StreamWriter("c :\\docnc.xml");
Line 40: //Create header
Line 41: nc.xhdr.RECIPIE NT = "GEW_EASINE T";
Line 42: nc.xhdr.TYPE = "ESP_CUSTOM ER";
Line 43: nc.xhdr.SENDER = "GEW_WEB";
I know I wrote before a week ago when I knew even less than now but I am
getting better please anyone give me a clue or an example. Am I completely
off track?
I have a datarow in a table with the fields to map to an xsd. Then i call a
web service upload method that wants the xml strongly typed to the xsd in a
string.
--
cindy
Feb 1 '07 #1
0 2788

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4445
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a problem with defining my JDBC resource within Tomcat. I am pretty sure that my code is correct (but I am not certain), and the problem is with defining the resource in Tomcat. Has anyone done this before? Any advice would be helpful.
0
4422
by: gagans | last post by:
Hi My web service has a method which accepts byte array as parameter. <WebMethod()> _ Public Function SendLoan(ByVal data As Byte()) As String Dim filePath As String filePath = System.AppDomain.CurrentDomain.BaseDirectory() & "\WorkingFiles\" objImportExport = New BrainImportExport.BrainImportExport SendLoan = objImportExport.ImportLoanByLoan(data, filePath) objImportExport = Nothing
8
2581
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
0
1903
by: Fraser Dickson | last post by:
I am building a web based system using ASP.NET and VB.NET which has to interact with a web service which uses XML WDDX packets. I have been given the XML Packet Specification by the Web Service Provider but can't work out the best way to interact with the WDDX packets. Basically the way the Web Service works is that you send a WDDX formatted Request packet to the given URL, their
0
1057
by: Navin Mishra | last post by:
Hi, I've a service that connects to the clients via TCP and sends data on client's opened TCP port. The data is in XML and I use ASCII encoding. There is 8 byte of header containing length of data in text appended to the TCP payload. So, if 1260 bytes of data needs to be sent, the header pre-pended is 00001260 and total 1268 bytes is sent. It works fine on my developoment and test system. Until on another system sometimes the 8 bytes...
6
17205
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
2
2087
by: Jonathan Woods | last post by:
Hi there, I have encountered problem of losing data sending over internet using web service. I consume web service that connected Oracle Database. I submit 687 SOAP Messages to 1 Web Method concurrently. (With synchronize method) public bool SubmitDPSuccessResult(string dpNo,string tkNo,string
0
1558
by: khubieb | last post by:
Simply I am trying to use RSACryptoServiceProvider to generate a key pair, send the public key to a service that will retrieve me data, encrypt it with my public key, send the encrypted data back for me to decrypt the data and use it. below is a code sample that simulates my task. It works just fine, however, when I turn impersonation to true in my web.config file and after a random number of attempts to invoke my page, an unhandled...
2
2576
by: rn5a | last post by:
I have created the following WebService named NConnect.asmx using which I want an ASPX page to first authenticate a user & after successful user validation, the ASPX page should display a few TextBoxes for users to enter some data in those TextBoxes which will finally be inserted in a SQL Server 2005 DB table: <%@ WebService Language="VB" Class="NConnect" %> Imports System Imports System.Data
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.