You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ranjit_d <ra...@rediffmail.com> on 2009/04/17 10:39:48 UTC

How to alter xml output of SOAP reponse

Hi,
I’m using Axis2 to provide a web service, but it would helpful if I could
customize the SOAP response.
Right now I’m getting the response as mentioned below, But I have to
eliminate the tags <ns:getReportDetailsResponse> and <ns:return>

<ns:getReportDetailsResponse xmlns:ns="https://xyz.com/xyz-ws/xsd">
<ns:return>
<root>
.
.
.
</root>
</ns:return>
</ns:getReportDetailsResponse>

Does anybody have idea about how to do it?

Thanks in advance!

i have added wsdl, xsd, and service.xml details below,

<!--------------------------------------------------------------DataService.wsdl------------------------------------------------------------------------------>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:sws="https://xyz.com/xyz-ws"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns="https://xyz.com/xyz-ws/xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:swr="https://xyz.com/xyz-ws/schemas/xyzwsResponse"
targetNamespace="https://xyz.com/xyz-ws">
	<wsdl:types>
		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="https://xyz.com/xyz-ws/xsd">
		
			<xs:element name="getReportDetails">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="eid" nillable="true" type="xs:string"/>
					    <xs:element name="userName" nillable="true" type="xs:string"/>
					    <xs:element name="dataSample" nillable="true" type="xs:string"/>
					    <xs:element name="sampleDef" nillable="true" type="xs:string"/>
						<xs:element name="reportType" nillable="true" type="xs:string"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:schema>			
	</wsdl:types>

	<wsdl:message name="getReportDetailsMessage">
		<wsdl:part name="part1" element="ns:getReportDetails"/>
	</wsdl:message>

	<wsdl:portType name="DataServicePortType">
		<wsdl:operation name="getReportDetails">
			<wsdl:input message="sws:getReportDetailsMessage"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
wsaw:Action="ns:getReportDetails"/>
			<wsdl:output message="sws:ResponseMessage"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
wsaw:Action="ns:getReportDetails"/>
		</wsdl:operation>
	</wsdl:portType>

	<wsdl:binding name="DataServiceSOAP11Binding"
type="sws:DataServicePortType">
		<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
		
		<wsdl:operation name="getReportDetails">
			<soap:operation soapAction="ns:getReportDetails" style="document"/>
			<wsdl:input>
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>	
	</wsdl:binding>
	
	<wsdl:binding name="DataServiceSOAP12Binding"
type="sws:DataServicePortType">
		<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
		
		<wsdl:operation name="getReportDetails">
			<soap12:operation soapAction="ns:getReportDetails" style="document"/>
			<wsdl:input>
				<soap12:body use="literal"/>
			</wsdl:input>
			<wsdl:output>
				<soap12:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	
	<wsdl:service name="DataService">
		<wsdl:port name="DataServiceSOAP11port"
binding="sws:DataServiceSOAP11Binding">
			<soap:address location="https://xyz.com/xyz-ws/services/DataService"/>
		</wsdl:port>
		<wsdl:port name="DataServiceSOAP12port"
binding="sws:DataServiceSOAP12Binding">
			<soap12:address location="https://xyz.com/xyz-ws/services/DataService"/>
		</wsdl:port>
	</wsdl:service>
	
</wsdl:definitions>		


<!--------------------------------------------------------------service.xml---------------------------------------------------------------------------------->

<service name="DataService"
targetNamespace="https://localhost:8080/xyz-ws/schemas/xyzwsResponse" >
    <description>xyz web services</description>
    <parameter name="ServiceObjectSupplier" locked="false">
       
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
    </parameter>
    
    <parameter name="SpringBeanName"
locked="false">axis2ServiceEndpoint</parameter>
    <operation name="getReportDetails" />
    
    <messageReceivers>
          <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" 
                          
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
          <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"  
                          
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    
</service>


<!--------------------------------------------------------------xyzWSResponse.xsd---------------------------------------------------------------------------------->


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:dop="https://localhost:8080/xyz-ws/schemas/xyzwsResponse"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://localhost:8080/xyz-ws/schemas/xyzwsResponse">
	<xsd:annotation>
		<xsd:documentation xml:lang="eng">Output XML schema </xsd:documentation>
	</xsd:annotation>

	<xsd:element name="root">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="dataC" type="dop:DataContextType" minOccurs="0"/>
				<xsd:element name="meta" type="dop:MetadataType"/>
				<xsd:element name="cData" type="dop:DataType" minOccurs="0"
maxOccurs="unbounded"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:complexType name="MetadataType">
		..................
	</xsd:complexType>	
	.............................
	
</xsd:schema>
	
-- 
View this message in context: http://www.nabble.com/How-to-alter-xml-output-of-SOAP-reponse-tp23093551p23093551.html
Sent from the Axis - User mailing list archive at Nabble.com.