HELLO , GOOD NEWS I HAVE TRIED THE CODE BELLOW , I HAVE 80 % PROGRESS BUT I DONT KNOW HOW TO COMPLETE THIS IS TOO LOGICAL
HERE IS MY CODE AND MY RESULT
SELECT ( SELECT 'BRO3886' AS MerchantReference
FOR
XML PATH(''),
TYPE
),
( SELECT '0' as 'Status', recid AS 'CustReference',
matricno AS 'CustomerReferenceAlternate',
fullname AS 'FirstName',
' ' AS 'LastName', email AS 'Email',
mobileno AS 'Phone',
'4747' AS 'ThirdPartyCode',
'50000.00' AS 'Amount'
FROM students WHERE username ='EGBUDUDU'
FOR
XML PATH('Customer'),ROOT('Customers'),
TYPE
)
FOR XML PATH(''),
ROOT('CustomerInformationResponse')
GO
..and XML serialization is handled automatically in ASP web services. Generally, there is no need to serialize data in SQL unless you have a very sepcific business need.
Member
29 Points
114 Posts
Creating web service that return xml format data
Jan 31, 2017 04:21 PM|aliyuusman4u|LINK
Hello,
I an challenged to develop web service that return xml formatted data using format bellow please how can i do that
<CustomerInformationResponse>
<MerchantReference>639</MerchantReference>
<Customers>
<Customer>
<Status>0</Status>
<CustReference>23470</CustReference>
<CustomerReferenceAlternate> </CustomerReferenceAlternate>
<FirstName>test test</FirstName>
<LastName> </LastName>
<Email>tester@gmail.com</Email>
<Phone> </Phone>
<ThirdPartyCode> </ThirdPartyCode>
<Amount>234078</Amount>
<PaymentItems>
<Item>
<ProductName>PayAtBank</ProductName>
<ProductCode>01</ProductCode>
<Quantity>1</Quantity>
<Price>234078</Price>
<Subtotal>234078</Subtotal>
<Tax>0</Tax>
<Total>234078</Total>
</Item>
</PaymentItems>
</Customer>
</Customers>
</CustomerInformationResponse>
PLEASE I NEED A HINT
Member
29 Points
114 Posts
Re: Creating web service that return xml format data
Feb 01, 2017 01:25 AM|aliyuusman4u|LINK
HELLO , GOOD NEWS I HAVE TRIED THE CODE BELLOW , I HAVE 80 % PROGRESS BUT I DONT KNOW HOW TO COMPLETE THIS IS TOO LOGICAL
HERE IS MY CODE AND MY RESULT
SELECT ( SELECT 'BRO3886' AS MerchantReference
FOR
XML PATH(''),
TYPE
),
( SELECT '0' as 'Status', recid AS 'CustReference',
matricno AS 'CustomerReferenceAlternate',
fullname AS 'FirstName',
' ' AS 'LastName', email AS 'Email',
mobileno AS 'Phone',
'4747' AS 'ThirdPartyCode',
'50000.00' AS 'Amount'
FROM students WHERE username ='EGBUDUDU'
FOR
XML PATH('Customer'),ROOT('Customers'),
TYPE
)
FOR XML PATH(''),
ROOT('CustomerInformationResponse')
GO
THE RESULT BELLOW
<CustomerInformationResponse>
<MerchantReference>BRO3886</MerchantReference>
<Customers>
<Customer>
<Status>0</Status>
<CustReference>395</CustReference>
<CustomerReferenceAlternate>12441001</CustomerReferenceAlternate>
<FirstName>EGBUDUDU SATURDAY O</FirstName>
<LastName> </LastName>
<Email>favourjoe84@yahoo.com</Email>
<Phone>08074233425</Phone>
<ThirdPartyCode>4747</ThirdPartyCode>
<Amount>50000.00</Amount>
</Customer>
</Customers>
</CustomerInformationResponse>
EXPECTED RESULT BELLOW
<CustomerInformationResponse>
<MerchantReference>639</MerchantReference>
<Customers>
<Customer>
<Status>0</Status>
<CustReference>23470</CustReference>
<CustomerReferenceAlternate> </CustomerReferenceAlternate>
<FirstName>test test</FirstName>
<LastName> </LastName>
<Email>tester@gmail.com</Email>
<Phone> </Phone>
<ThirdPartyCode> </ThirdPartyCode>
<Amount>234078</Amount>
<PaymentItems>
<Item>
<ProductName>PayAtBank</ProductName>
<ProductCode>01</ProductCode>
<Quantity>1</Quantity>
<Price>234078</Price>
<Subtotal>234078</Subtotal>
<Tax>0</Tax>
<Total>234078</Total>
</Item>
</PaymentItems>
</Customer>
</Customers>
</CustomerInformationResponse>
THANK YOU VERY MUCH
Member
29 Points
114 Posts
Re: Creating web service that return xml format data
Feb 01, 2017 01:27 AM|aliyuusman4u|LINK
HOW DO I PUT THIS INTO THE XML FORMATING TO GIVE ME THE EXACT DESIRED RESULT
<PaymentItems>
<Item>
<ProductName>PayAtBank</ProductName>
<ProductCode>01</ProductCode>
<Quantity>1</Quantity>
<Price>234078</Price>
<Subtotal>234078</Subtotal>
<Tax>0</Tax>
<Total>234078</Total>
</Item>
</PaymentItems>
All-Star
52261 Points
23317 Posts
Re: Creating web service that return xml format data
Feb 01, 2017 04:50 PM|mgebhard|LINK
XML serialization is a core feature of .NET. ..
https://msdn.microsoft.com/en-us/library/ms973893.aspx
..and XML serialization is handled automatically in ASP web services. Generally, there is no need to serialize data in SQL unless you have a very sepcific business need.
https://msdn.microsoft.com/en-us/library/ms972326.aspx
https://msdn.microsoft.com/en-us/library/aa702682(v=vs.110).aspx
https://www.asp.net/web-api