Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SOAP message to XML

 
BhanuSp Prakash
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Is there a way to convert SOAP response to XML? I tried to use JAXB but it is giving error. I am pasting the SOAP response below. Please let me know how to convert this to XML.


SOAP Response
=============

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns0:HelpDesk_Query_ServiceResponse xmlns:ns0="urn:HPD_IncidentInterface_WS">
<ns0:Assigned_Group>Internal Support</ns0:Assigned_Group>
<ns0:Assigned_Group_Shift_Name/>
<ns0:Assigned_Support_Company>My Company</ns0:Assigned_Support_Company>
<ns0:Assigned_Support_Organization>IT Support Organization</ns0:Assigned_Support_Organization>
<ns0:Assignee>uOrch6 uOrch6</ns0:Assignee>
<ns0:Categorization_Tier_1/>
<ns0:Categorization_Tier_2/>
<ns0:Categorization_Tier_3/>
<ns0:City>Schiphol-Rijk</ns0:City>
<ns0:Closure_Manufacturer/>
<ns0:Closure_Product_Category_Tier1/>
<ns0:Closure_Product_Category_Tier2/>
<ns0:Closure_Product_Category_Tier3/>
<ns0:Closure_Product_Model_Version/>
<ns0:Closure_Product_Name/>
<ns0:Company>My Company</ns0:Company>
<ns0:Contact_Company>My Company</ns0:Contact_Company>
<ns0:Contact_Sensitivity>Standard</ns0:Contact_Sensitivity>
<ns0:Country>Netherlands</ns0:Country>
<ns0epartment/>
<ns0:Summary>Desktop Not Working</ns0:Summary>
<ns0:Notes>Desktop Not Working</ns0:Notes>
<ns0:First_Name>ATG</ns0:First_Name>
<ns0:Impact>3-Moderate/Limited</ns0:Impact>
<ns0:Last_Name>USER</ns0:Last_Name>
<ns0:Manufacturer/>
<ns0:Middle_Initial/>
<ns0:Organization/>
<ns0:Phone_Number>###</ns0:Phone_Number>
<ns0:Priority>Medium</ns0:Priority>
<ns0:Priority_Weight>13</ns0:Priority_Weight>
<ns0:Product_Categorization_Tier_1/>
<ns0:Product_Categorization_Tier_2/>
<ns0:Product_Categorization_Tier_3/>
<ns0:Product_Model_Version/>
<ns0:Product_Name/>
<ns0:Region>EMEA</ns0:Region>
<ns0:Reported_Source/>
<ns0:Resolution/>
<ns0:Resolution_Category/>
<ns0:Resolution_Category_Tier_2/>
<ns0:Resolution_Category_Tier_3/>
<ns0:Service_Type>User Service Restoration</ns0:Service_Type>
<ns0:Site>EMEA Training Center</ns0:Site>
<ns0:Site_Group>Amsterdam Training Center</ns0:Site_Group>
<ns0:Status>Assigned</ns0:Status>
<ns0:Status_Reason/>
<ns0:Urgency>3-Medium</ns0:Urgency>
<ns0:VIP>No</ns0:VIP>
</ns0:HelpDesk_Query_ServiceResponse>
</soapenv:Body>
</soapenv:Envelope>


=========================================================


Thanks
Bhanu
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you explain the circumstances of your application more? All web service stacks already convert SOAP to java objects ... I'm not clear why you want to do it explicitly using JAXB.
 
BhanuSp Prakash
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,

I am trying to post an XML to a Rest Webservice. In the REST webservice, i am trying to manipulate the XML and posting it to the ISTM webserive which will create a ticket in BMC Remedy ITSM system. I will get the reponse back from the ITSM system with all the ticket details as specified in the query. As the response from ITSM is a SOAP message, it is difficuilt for the users to understand it. So I am trying to transform it to a XML.

I tried using JAXB, but i am getting exception.

Thanks
Bhanu
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the response from ITSM is a SOAP message, it is difficuilt for the users to understand it. So I am trying to transform it to a XML.


BUT all SOAP messages are already XML documents so you can use normal Java methods to locate values with XPath, transform with XSLT, etc etc - there is absolutely no need to get involved with JAXB.

Bill
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I feel that since the ITSM web service is a SOAP style WS, the path of least maintenance is to use it as a SOAP style WS.
Its WSDL should be the one and only contract.
By trying to manipulate its SOAP representation, you'll introduce a rather fragile coupling to the SOAP binding instead of the WSDL.
If that service ever changes its SOAP bindings even slightly (which can happen if they change their WS stack), your code will need modifications.
Instead, I feel your REST webservice component should become a proper SOAP WS client to the ITSM webservice (the JAXWS implementation that comes with the JRE should make it a simple enough implementation. Prototype and try out.). Using JAXWS, you'll get back some POJOs from that web service. Then convert those POJOs' fields to your user friendly XML format, using XStream / JAXB / DOM,....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic