IUSR
asked on
WCF service with list array request
Hi,
i'm newbie in C# and web service but i need to read the soap service (xml format) and save it to a SQL tables (dataset)...
here's my client's data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pix="">
<soapenv:Header/>
<soapenv:Body>
<tem:Request>
<pix:wsVersion>v1.2.1</pix :wsVersion >
<pix:cname>Testaccount</pi x:cname>
<pix:sclass>sales</pix:scl ass>
<pix:PO>PO12345</pix:PO>
<pix:method>AIR</pix:metho d>
<pix:product>
<pix:style>Abc1</pix:style >
<pix:qty>1</pix:qty>
<pix:price>1.00</pix:price >
</pix:product>
<pix:product>
<pix:style>Cde1</pix:style >
<pix:qty>2</pix:qty>
<pix:price>1.00</pix:price >
</pix:product>
</tem:Request>
</soapenv:Body>
</soapenv:Envelope>
I have 2 classes:
class order
[MessageBodyMember(Order = 0)]
public string wsVersion { get; set; }
[MessageBodyMember(Order = 1)]
public string cname { get; set; }
[MessageBodyMember(Order = 2)]
public string PO { get; set; }
[MessageBodyMember(Order = 3)]
public string method { get; set; }
[MessageBodyMember(Order = 4)]
[XmlArrayItem("oItems", IsNullable = false)]
public Item[] Items { get; set; }
class Item
[XmlElement(Order = 0)]
public string style { get; set; }
[XmlElement(Order = 1)]
public int qty { get; set; }
[XmlElement(Order = 2)]
public double price { get; set; }
in service.svc.cs
wsVersion = httpUtility.HtmlEncode(req uest.wsVer sion);
cname= httpUtility.HtmlEncode(req uest.cname );
PO= httpUtility.HtmlEncode(req uest.PO);
method= httpUtility.HtmlEncode(req uest.metho d);
items = new Item();
listItem = new List<Item>();
listItem.style = HttpUtility.HtmlEncode(req uest.item. style()); <---
i do not know how to read the xml element array, should i just use reader at the very beginning?
can someone give me a hint or something? should i not use httpUtility.HtmlEncode?...
thank you!
i'm newbie in C# and web service but i need to read the soap service (xml format) and save it to a SQL tables (dataset)...
here's my client's data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pix="">
<soapenv:Header/>
<soapenv:Body>
<tem:Request>
<pix:wsVersion>v1.2.1</pix
<pix:cname>Testaccount</pi
<pix:sclass>sales</pix:scl
<pix:PO>PO12345</pix:PO>
<pix:method>AIR</pix:metho
<pix:product>
<pix:style>Abc1</pix:style
<pix:qty>1</pix:qty>
<pix:price>1.00</pix:price
</pix:product>
<pix:product>
<pix:style>Cde1</pix:style
<pix:qty>2</pix:qty>
<pix:price>1.00</pix:price
</pix:product>
</tem:Request>
</soapenv:Body>
</soapenv:Envelope>
I have 2 classes:
class order
[MessageBodyMember(Order = 0)]
public string wsVersion { get; set; }
[MessageBodyMember(Order = 1)]
public string cname { get; set; }
[MessageBodyMember(Order = 2)]
public string PO { get; set; }
[MessageBodyMember(Order = 3)]
public string method { get; set; }
[MessageBodyMember(Order = 4)]
[XmlArrayItem("oItems", IsNullable = false)]
public Item[] Items { get; set; }
class Item
[XmlElement(Order = 0)]
public string style { get; set; }
[XmlElement(Order = 1)]
public int qty { get; set; }
[XmlElement(Order = 2)]
public double price { get; set; }
in service.svc.cs
wsVersion = httpUtility.HtmlEncode(req
cname= httpUtility.HtmlEncode(req
PO= httpUtility.HtmlEncode(req
method= httpUtility.HtmlEncode(req
items = new Item();
listItem = new List<Item>();
listItem.style = HttpUtility.HtmlEncode(req
i do not know how to read the xml element array, should i just use reader at the very beginning?
can someone give me a hint or something? should i not use httpUtility.HtmlEncode?...
thank you!
ASKER
Hi Rainer,
yes, i'm developing a WCF service, the client will send me the SOAP structure request and i reply with order number.
but i'm having problem reading the request, i can read the single nodes without any issue but the product array is difficult and i do not know how many items will be.
-i tried xml deserialize the whole request but encounter the "Object reference not set to an instance of an object."
-trying the FastMember from NuGet Packages but the red wavy underline showing my array object is unknown...
any suggestion on how to properly read xml request with array items is greatly appreciate...
yes, i'm developing a WCF service, the client will send me the SOAP structure request and i reply with order number.
but i'm having problem reading the request, i can read the single nodes without any issue but the product array is difficult and i do not know how many items will be.
-i tried xml deserialize the whole request but encounter the "Object reference not set to an instance of an object."
-trying the FastMember from NuGet Packages but the red wavy underline showing my array object is unknown...
any suggestion on how to properly read xml request with array items is greatly appreciate...
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
sorry,but I could not fully understand the question.
Are you developing a WCF service which should get the above SOAP structure?
Or are you consuming another service which returns the above elements?
Thanks for clarification,
Rainer