Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi am new person in that kindly help or suggest me what i have to do or use to solve this problem. I have a multiline text box and i have to paste the xml file in it and on button click i have to call a webservices which return the output in another multiline textbox over the page my problem is that when i entered the xml file in side textbox so how i read and call webservice which read xml data as well as return the output in another text box. My code is just like : please respond me as soon as possible.

Instructions:
Write a web service in C#. It will accept XML input and send XML output. You also need to write a test page for testing the web service.

Test Page
This should be asp.net web page having 3 elements
1. request box , where we can paste XML input
2. button , on clicking this, the XML input will be sent to web service
3. response box, where we can see what web service returned

Web service

Web service should have 1 web method named processTransaction. It will accept the XML input pasted in test page.

Example of XML input
HTML
<transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    xmlns="http://www.exchangefortravel.org/xft/current" xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:dx="http://www.afidium.com/dx" Target="Test" TimeStamp="2006-05-11T14:47:40.477+02:00"
    xsi:type="TransactionRequestType"&gt;
    <control>
        <requester>
            <company code="VDM" uid="AFD01" />
            <agency uid="MonAgence" pwd="MonPwd" />
            <brand>
                <code role="Reference" key="1" />
            &lt;/Brand&gt;
        &lt;/Requester&gt;
        &lt;Vendors&gt;
            &lt;Vendor Code="TOURMAPPERS"/&gt;
            &lt;Vendor Code="ABBEYTOURSSCOTLAND"/&gt;
        &lt;/Vendors&gt;
        &lt;Host Code="AFIDIUM"/&gt;
    &lt;/Control&gt;
    &lt;Action Purpose="Search" Code="QuotedAvailability"&gt;
        &lt;RecordSet First="1" Count="40"/&gt;
    &lt;/Action&gt;
    &lt;Style&gt;
        &lt;Currency Code="EUR" Decimals="2"/&gt;
        &lt;Stock Filter="Include"/&gt;
    &lt;/Style&gt;
    &lt;Trip&gt;
        &lt;Segment xsi:type="SegmentProductType"&gt;
            &lt;Code Role="Keyword" Owner="VDM"&gt;
                &lt;Codes&gt;
                    &lt;Code Value="HONEYMOON"/&gt;
                    &lt;Code Value="SOMETINGELSE"/&gt;
                &lt;/Codes&gt;

            <segments what="List">
                <segment xsi:type="SegmentStayType">
                    <at>
                        <room>
                            <travellers>
                                <traveller ref="T1" />
                                <traveller ref="T2" />
                            </travellers>
                        </room>
                    </at>
                </segment>
            </segments>
            <begin value="2012-12-25" />
            <end value="2012-12-31" />

        <travellers>
            <traveller type="Adult" id="T1" />
            <traveller type="Adult" id="T2" />
        </travellers>

</brand></requester></control></transaction>


Flow:
1. Extract Action/@Purpose , Action/@Code
2. Extract all Vendors/Vendor/@Code.
3. Extract Begin and End dates
4. Form a string with above extracted information. For the given XML input, the string will look like You requested to process Search QuotedAvailability for TOURMAPPERS, ABBEYTOURSSCOTLAND vendors for check in date 2012-12-25 and checkout date 2012-12-31

If vendors are not found, then the string should NOT have this part
for TOURMAPPERS, ABBEYTOURSSCOTLAND vendors

The dates and action node should always be present. So if these are not found, then the string message will be
Invalid input


5. Form the XML output . For given input, the output will be
HTML
<transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    xmlns="http://www.exchangefortravel.org/xft/current" xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:dx="http://www.afidium.com/dx" Target="Test" TimeStamp="2006-05-11T14:47:40.477+02:00"
    xsi:type="TransactionResponseType"&gt;
    <control>
        <requester>
            <company code="VDM" uid="AFD01" />
            <agency uid="MonAgence" pwd="MonPwd" />
            <brand>
                <code role="Reference" key="1" />
            &lt;/Brand&gt;
        &lt;/Requester&gt;
        &lt;Vendors&gt;
            &lt;Vendor Code="TOURMAPPERS"/&gt;
            &lt;Vendor Code="ABBEYTOURSSCOTLAND"/&gt;
        &lt;/Vendors&gt;
        &lt;Host Code="AFIDIUM"/&gt;
    &lt;/Control&gt;
    &lt;Action Purpose="Search" Code="QuotedAvailability"&gt;
        &lt;Code&gt;&lt;![CDATA[You requested to process Search QuotedAvailability for TOURMAPPERS, ABBEYTOURSSCOTLAND vendors for check in date 2012-12-25 and checkout date 2012-12-31
        <recordset first="1" count="40" />

</brand></requester></control></transaction>

Please note that in this case, the Transaction element looks exactly like request. However, xsi:type changes to TransactionResponseType. Control element is also exactly same as in request

In case of "invalid input", the output should look like following. Here we construct the Transaction element ourselves.
HTML
<transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    xmlns="http://www.exchangefortravel.org/xft/current" xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:dx="http://www.afidium.com/dx" Target="Test"
    xsi:type="TransactionResponseType"&gt;
    <action>
        <code>&lt;![CDATA[Invalid Input</code>
    </action>
</transaction>
Posted
Updated 6-Jun-15 23:12pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900