473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

accessing an xml schema through a web service (C#)

Hi All,

I am trying write a small web app which inserts a purchase order through an xml schema that I have exposed through a web service(using Biztalk 2004). I have that the PO can have many articles but I am not sure how the code should be for inserting each article? Here is the xml schema and below that is the button_click function I have wrote in C#.

[HTML]
<xs:element name="PO">
<xs:complexType>
<xs:sequence>
<xs:element name="ToSupplier" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="unbounded" name="Articles">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="Article">
<xs:complexType>
<xs:sequence>
<xs:element name="SupplierArticleGUID" type="xs:string" />
<xs:element name="SupplierArticlePriceGUID" type="xs:string" />
<xs:element name="Quantity" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="IssuedBy" type="xs:string" />
<xs:element name="ApprovalState" type="xs:int" />
</xs:sequence>
<xs:attribute name="OrderDate" type="xs:date" />
<xs:attribute name="Total" type="xs:decimal" />
</xs:complexType>
</xs:element>
[/HTML]
here is the function to insert the PO:
Expand|Select|Wrap|Line Numbers
  1. private void Button1_Click(object sender, System.EventArgs e)
  2.   {
  3.    localhost.PO oPO;
  4.    localhost.POArticles oPOA;
  5.    localhost.POArticlesArticle oPOAA;
  6.  
  7.    localhost.PurchaseOrderProcess_Orchestration_1_PurchaseOrderIN_Port oWSMethodCall;
  8.  
  9.    oPO = new localhost.PO();
  10.    oPOA = new localhost.POArticles();
  11.    oPOAA = new localhost.POArticlesArticle();
  12.    oWSMethodCall = new localhost.PurchaseOrderProcess_Orchestration_1_PurchaseOrderIN_Port();
  13.  
  14.    oPO.OrderDate = System.DateTime.Now;
  15.    oPO.Total = 11.50m; 
  16.    oPO.ToSupplier = System.Guid.NewGuid().ToString();
  17.    oPO.ApprovalState = 1;
  18.    oPO.IssuedBy = "Jane Doe";
  19.  
  20.  
  21.    oPOAA.SupplierArticleGUID = System.Guid.NewGuid().ToString();
  22.    oPOAA.SupplierArticlePriceGUID = System.Guid.NewGuid().ToString();
  23.    oPOAA.Quantity = 3;
  24.    oPOA.Article = oPOAA;
  25.    oPO.Articles.Initialize();  
  26.    oPO.Articles.SetValue(oPOA,0);
  27.  
  28.    oWSMethodCall.Operation_1(oPO);
  29.  
  30.   }
  31.  
  32.  
On the highlighted line I get the following error: Object reference not set to an instance of an object.

I would appreciate any help!!
Aug 17 '07 #1
9 2177
jkmyoung
2,057 Expert 2GB
guessing you need to add this line before that:
oPO.Articles = oPOA;

Otherwise, oPO.Articles will still be null.
Aug 17 '07 #2
Hi thanks for replying!

Well I was following a tutorial and that was exactly what it said to do but when I try that I get the error: Cannot implicitly convert type 'PODriver.localhost.POArticles' to 'PODriver.localhost.POArticles[]'

so I changed it to the last 2 lines. Do you know how I would correct this error then?
Aug 17 '07 #3
Hi, I am still stuck on this problem and I would really really appreciate it if anyone could take the time and explain to me how I am supposed to initialise this array in order to insert the articles.
Aug 18 '07 #4
jkmyoung
2,057 Expert 2GB
2nd guess then:
oPO.Articles = new localhost.POArticles[1];
oPO.Articles[0] = oPOA;

Do you have any documentation on the PODriver class?
Aug 20 '07 #5
Oh thanks a million it works now!! Only thing is that it inserts 'null' values for the lines:

oPO.OrderDate = System.DateTime.Now;
(datatype = System.Decimal) oPO.Total = 11.50m;

do you know how I solve this?

Thanks again for your help!
Aug 20 '07 #6
jkmyoung
2,057 Expert 2GB
Do you have the link to the tutorial?
Aug 21 '07 #7
Well this is the tutorial I was following but I changed it around to use with the way I needed it, though the two values I am having problems with are different then the tutorial. One is for the current date and the other is of type decimal. Is there something particular that has to be done for these types?

http://www.codeguru.com/cpp/i-n/inte...cle.php/c7785/
Aug 22 '07 #8
jkmyoung
2,057 Expert 2GB
Note that you're having a problem with the attributes.
If you're allowed to edit the xml that comes out, I suggest recasting these as elements, at least for the time being.

You probably have to set attributes differently in Biztalk.
Aug 26 '07 #9
Oh thanks, you are right I didn't realise that! I will change them to elements, its easier!
Aug 28 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mike P | last post by:
I have a web app that has been running happily for months, and on Saturday it suddenly decided that it no longer wanted to validate my XML. Here is my code and sample schema, and example XML : ...
1
by: RA | last post by:
Hi I have an xml schema and I have created a dataset from that schema. I have a web service that recieve info and sends back an xml information. I send back the xml using SchemaDataset.WriteXml...
1
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i...
5
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in...
0
by: billmiami2 | last post by:
I'm creating an ASP.NET web service with a number of web methods. The consumers of these web services are developers using Macromedia Flash which comes with its own interface for web services. In...
3
by: kkao77 | last post by:
I am trying to use schema to validate the data that user sent to my service. How do I achieve that using schema? Do I give schema to the client? or do I write my own schema validation inside web...
1
by: Sandy | last post by:
I am defining a web service to receive data that represents an application form and that returns a message indicating if the application form has been successfully validated or not, listing any...
2
by: SteveChamp | last post by:
I have been experimenting with .Net web services for a while and have a few questions about the schema in the automatically generated WSDL file, and whether its content can be manipulated...
1
by: leno | last post by:
Hi all, I'm having this problem when i combined multiple schema's into one. The error msg is below: Unable to load schema with target namespace 'http://www.tdbanknorth.com/IFX170_TDBN' from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.