473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
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="ToSupplie r" type="xs:string " />
<xs:element minOccurs="1" maxOccurs="unbo unded" name="Articles" >
<xs:complexType >
<xs:sequence minOccurs="1" maxOccurs="unbo unded">
<xs:element name="Article">
<xs:complexType >
<xs:sequence>
<xs:element name="SupplierA rticleGUID" type="xs:string " />
<xs:element name="SupplierA rticlePriceGUID " 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="ApprovalS tate" type="xs:int" />
</xs:sequence>
<xs:attribute name="OrderDate " type="xs:date" />
<xs:attribute name="Total" type="xs:decima l" />
</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 2225
jkmyoung
2,057 Recognized Expert Top Contributor
guessing you need to add this line before that:
oPO.Articles = oPOA;

Otherwise, oPO.Articles will still be null.
Aug 17 '07 #2
turnips11
8 New Member
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.local host.POArticles ' to 'PODriver.local host.POArticles[]'

so I changed it to the last 2 lines. Do you know how I would correct this error then?
Aug 17 '07 #3
turnips11
8 New Member
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 Recognized Expert Top Contributor
2nd guess then:
oPO.Articles = new localhost.POArt icles[1];
oPO.Articles[0] = oPOA;

Do you have any documentation on the PODriver class?
Aug 20 '07 #5
turnips11
8 New Member
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 Recognized Expert Top Contributor
Do you have the link to the tutorial?
Aug 21 '07 #7
turnips11
8 New Member
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 Recognized Expert Top Contributor
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
turnips11
8 New Member
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
1303
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 : public void ValidateAgainstSchema(object sender, ValidationEventArgs args) { blnInvalidXML = true; }
1
1709
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 (...) A consumer of the web service then call a different method of the web service which takes an xml string as an input parameter. I need to load this xml string into the Schemadataset. I do that using the following:
1
6408
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 reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
5
5402
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 separate files for ease of maintainability. These schemas are all part of the same namespace. When defining a web service that access more than one of these entities, the wsdl file generated by BEA contains multiple schema elements with the same...
0
1197
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 order that these developers can take full advantage of the web services, it appears that I need to return output data types in my service description (i.e., before the method is called and the dataset returned), not just input data types. Note...
3
1378
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 service? How does it work? Thank you.
1
3327
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 errors. I would like to use XPath to define the validation rules that will be executed within the web service. Clearly, to do this my data has to be in XML format. However, I would like my WSDL to describe explicitly the schema of the
2
2038
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 programatically. First of all, I created several very simple test methods in my web service: <WebMethod()_ Public Function TestString(ByVal test As String) As String Return "The value passed was " + test End Function
1
10964
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 'IFX170_TDBN.xsd'. combinedXSD: <xsd:schema xmlns:TDBN="http://www.tdbanknorth.com/WebServices" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:IFXTDBN="http://www.tdbanknorth.com/IFX170_TDBN" xmlns:IFX="http://www.tdbanknorth.com/IFX170_XSD"...
0
9628
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
10289
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...
1
10061
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
9923
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
7471
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
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.