Hi, I must admit..that i am relatively new in Web Service.I am given with a Request Schema and Response Schema. So, could you please let me know, in a XML based Web Service, how do i raise a request and hit the web method.
Could you please direct me to a link or sort of an walkthrough in this regard(with respect to request and response schema)
As Anna suggested, you can try using XSD.exe tool for generating some .NET helper classes, and use XML serialization to convert the class instances into XML message. Then you can use WebRequest class to send the XML message(as request) to service and retrieve
XML as response back.
If you're not quite familar with .NET xml serizliation, personally, I suggest that you try getting a sample request/response message pair from the service provider so that you can easily build the request message based on the sample (and also know how you
can use XML classes to parse the response). The webRequest/HttpWebRequest is the common class for sending HTTP GET/POST requests (which can also be used for making simple webservice or WCF operation calls)
nicetohaveyo...
Member
4 Points
18 Posts
XML Web Service Request and Response
Feb 22, 2012 09:55 AM|LINK
Hi, I must admit..that i am relatively new in Web Service.I am given with a Request Schema and Response Schema. So, could you please let me know, in a XML based Web Service, how do i raise a request and hit the web method.
Could you please direct me to a link or sort of an walkthrough in this regard(with respect to request and response schema)
Thanks
kushalrdalal
Contributor
7130 Points
1273 Posts
Re: XML Web Service Request and Response
Feb 22, 2012 12:45 PM|LINK
Check this url-
http://blog.vinodsingh.com/2009/12/send-xml-data-over-web-service.html
If you provide the structure of request/response then it would be easy to give an example.
My Blog
LinkedIn Profile
nicetohaveyo...
Member
4 Points
18 Posts
Re: XML Web Service Request and Response
Feb 23, 2012 05:16 AM|LINK
Request Schema below:
==============================================================================================
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://xmlns.ab.ae/AIX/AB_SERVICE_REQUEST" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.ab.ae/AIX/AB_SERVICE_REQUEST" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:complexType name="AB_SERVICE_REQUEST"> <xsd:sequence> <xsd:element name="HEADER" type="HEADER"/> <xsd:element name="BODY" type="BODY" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="HEADER"> <xsd:sequence> <xsd:element name="REQ_ID" type="xsd:string"/> <xsd:element name="SUB_SYSTEM" type="xsd:string"/> <xsd:element name="SER_SIGN" type="xsd:string"/> <xsd:element name="VERSION" type="xsd:string"/> <xsd:element name="EXPECTED_REPLY"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Low"/> <xsd:enumeration value="High"/> <xsd:enumeration value="Medium"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="ALLOW" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Y"/> <xsd:enumeration value="N"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="USER" type="xsd:string"/> <xsd:element name="PWD" type="xsd:string"/> <xsd:element name="SCHEDULE" type="xsd:dateTime" minOccurs="0"/> <xsd:element name="RELATION_ID" type="xsd:string" minOccurs="0"/> <xsd:element name="MODE" type="xsd:integer" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="BODY"> <xsd:sequence> <xsd:any namespace="##any" processContents="strict" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema> Response Schema below: =========================================================================================================== <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://xmlns.ab.ae/AIX/AB_SERVICE_REPLY" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.ab.ae/AIX/AB_SERVICE_REPLY" elementFormDefault="qualified"> <xsd:complexType name="AB_SERVICE_REQUEST"> <xsd:sequence> <xsd:element name="HEADER" type="HEADER"/> <xsd:element name="BODY" type="BODY" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="BODY"> <xsd:sequence> <xsd:any namespace="##any" processContents="strict" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="HEADER"> <xsd:sequence> <xsd:element name="RESPONSE_ID" type="xsd:string"/> <xsd:element name="MESSAGE" type="xsd:string" minOccurs="0"/> <xsd:element name="ERR_CODE" type="xsd:string" minOccurs="0"/> <xsd:element name="ERR_DESCRIPTION" type="xsd:string" minOccurs="0"/> <xsd:element name="REQ_ID" type="xsd:string" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema>Anna Sun
Participant
1798 Points
219 Posts
Re: XML Web Service Request and Response
Feb 24, 2012 06:53 AM|LINK
Try to use the xsd command to generate a class (using the /c switch).
Then in your web service method, you use the class as parameter/return type.
Refer to http://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.100).aspx for more information.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: XML Web Service Request and Response
Feb 28, 2012 09:32 AM|LINK
Hi,
As Anna suggested, you can try using XSD.exe tool for generating some .NET helper classes, and use XML serialization to convert the class instances into XML message. Then you can use WebRequest class to send the XML message(as request) to service and retrieve XML as response back.
#INFO: Roadmap for XML Serialization in the .NET Framework
http://support.microsoft.com/kb/314150
#How to serialize an object to XML by using Visual C#
http://support.microsoft.com/kb/815813
If you're not quite familar with .NET xml serizliation, personally, I suggest that you try getting a sample request/response message pair from the service provider so that you can easily build the request message based on the sample (and also know how you can use XML classes to parse the response). The webRequest/HttpWebRequest is the common class for sending HTTP GET/POST requests (which can also be used for making simple webservice or WCF operation calls)
#Invoking Web Service dynamically using HttpWebRequest h
ttp://geekswithblogs.net/marcel/archive/2007/03/26/109886.aspx
Feedback to us
Microsoft One Code Framework
nicetohaveyo...
Member
4 Points
18 Posts
Re: XML Web Service Request and Response
Feb 28, 2012 03:16 PM|LINK
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://xmlns.ab.ae/AIX/AB_SERVICE_REQUEST" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.ab.ae/AIX/AB_SERVICE_REQUEST" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:complexType name="AB_SERVICE_REQUEST"> <xsd:sequence> <xsd:element name="HEADER" type="HEADER"/> <xsd:element name="BODY" type="BODY" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="HEADER"> <xsd:sequence> <xsd:element name="REQ_ID" type="xsd:string"/> <xsd:element name="SUB_SYSTEM" type="xsd:string"/> <xsd:element name="SER_SIGN" type="xsd:string"/> <xsd:element name="VERSION" type="xsd:string"/> <xsd:element name="EXPECTED_REPLY"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Low"/> <xsd:enumeration value="High"/> <xsd:enumeration value="Medium"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="ALLOW" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Y"/> <xsd:enumeration value="N"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="USER" type="xsd:string"/> <xsd:element name="PWD" type="xsd:string"/> <xsd:element name="SCHEDULE" type="xsd:dateTime" minOccurs="0"/> <xsd:element name="RELATION_ID" type="xsd:string" minOccurs="0"/> <xsd:element name="MODE" type="xsd:integer" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="BODY"> <xsd:sequence> <xsd:any namespace="##any" processContents="strict" minOccurs="0"/> </xsd:sequence> </xsd:complexType> </xsd:schema> After putting the above in a file request.xsd. I ran the VS command prompt and typed in xsd /c request.xsd and it thrown the warning [Microsoft (R) .NET Framework, Version 2.0.50727.3038] Copyright (C) Microsoft Corporation. All rights reserved. Warning: cannot generate classes because no top-level elements with complex type were found. pls help...