Hello,
I am trying to create a new version of the "quickstartaxiom" sample,
with the StockQuoteService providing a getPriceFile operation which
returns a file using MTOM.
In the MTOM tutorial unfortunately there are only parts of code (I
cannot find a complete example in axis2-1.1.1 - the mtom sample is not
based on AXIOM) thus I had to write the other parts, but since I have
some problems in invoking the service I think I have made a mistake
somewhere.
My new ***AXIOMClient*** should set
options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
as explained in the tutorial, but the Options class has no "set"
method and I cannot find the right one..
Btw, I added to the client the following method:
public static OMElement getPriceFilePayload(String priceFileName) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://quickstart.samples/xsd", "tns");
OMElement method = fac.createOMElement("getPriceFile", omNs);
OMElement value = fac.createOMElement("priceFileName", omNs);
value.addChild(fac.createOMText(value, priceFileName));
method.addChild(value);
return method;
}
and in the main() method of the client I added the following part, for
getFilePrice invocation:
OMElement getPriceFilePayload = getPriceFilePayload("prova.txt");
.......
result = sender.sendReceive(getPriceFilePayload);
OMElement ele = result.getFirstElement();
OMText binaryNode = (OMText) ele.getFirstOMChild();
DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
File file = new File("prova.txt");
FileOutputStream fileOutputStream = new FileOutputStream(file);
actualDH.writeTo(fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
In the ***StockQuoteService*** the getPriceFile method is implemented
as follows:
public OMElement getPriceFile(OMElement element) throws XMLStreamException {
element.build();
element.detach();
OMElement fileNameElement = element.getFirstElement();
String fileName = fileNameElement.getText();
System.out.println("fileName = " + fileName);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs =
fac.createOMNamespace("http://quickstart.samples/xsd", "ns");
OMElement fileElement = fac.createOMElement("file", omNs);
FileDataSource dataSource =
new FileDataSource(fileName);
DataHandler dataHandler = new DataHandler(dataSource);
// create an OMText node with the above DataHandler and set
optimized to true
OMText textData = fac.createOMText(dataHandler, true);
fileElement.addChild(textData);
OMElement method = fac.createOMElement("getPriceFileResponse", omNs);
OMElement value = fac.createOMElement("priceFile", omNs);
value.addChild(textData);
method.addChild(value);
return method;
}
Is this ok? Where should I store the "prova.txt" file in the server?
In the same folder in which I put the *.aar file?
I attach to this mail the wsdl of the service, and the configuration file.
I am using Tomcat as servlet engine, and the logs are clean at the server side.
At the client side the error message is:
[java] org.apache.axiom.om.OMException: Referenced Attachment not
found in the MIME Message.
ContentID:1.urn:uuid:[EMAIL PROTECTED]
[java] at
org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder.getDataHandler(MTOMStAXSOAPModelBuilder.java:107)
[java] at
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:379)
[java] at samples.quickstart.clients.AXIOMClient.main(AXIOMClient.java:105)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[java] at java.lang.reflect.Method.invoke(Unknown Source)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
[java] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[java] at org.apache.tools.ant.Task.perform(Task.java:364)
[java] at org.apache.tools.ant.Target.execute(Target.java:341)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[java] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[java] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[java] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[java] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[java] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Thank you very much!
--
Michele Amoretti, Ph.D.
Distributed Systems Group
Dipartimento di Ingegneria dell'Informazione
Università degli Studi di Parma
http://www.ce.unipr.it/amoretti
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<wsdl:definitions xmlns:axis2="http://quickstart.samples/"
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="http://quickstart.samples/xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://quickstart.samples/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://quickstart.samples/xsd">
<xs:element name="getPriceFile">
<xs:complexType>
<xs:sequence>
<xs:element name="priceFileName" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="priceFile" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPrice">
<xs:complexType>
<xs:sequence>
<xs:element name="symbol" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="price" nillable="true" type="xs:double" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element name="symbol" nillable="true" type="xs:string" />
<xs:element name="price" nillable="true" type="xs:double" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getPriceFileMessage">
<wsdl:part name="part1" element="ns:getPriceFile" />
</wsdl:message>
<wsdl:message name="getPriceFileResponseMessage">
<wsdl:part name="part1" element="ns:getPriceFileResponse" />
</wsdl:message>
<wsdl:message name="getPriceMessage">
<wsdl:part name="part1" element="ns:getPrice" />
</wsdl:message>
<wsdl:message name="getPriceResponseMessage">
<wsdl:part name="part1" element="ns:getPriceResponse" />
</wsdl:message>
<wsdl:message name="updateMessage">
<wsdl:part name="part1" element="ns:update" />
</wsdl:message>
<wsdl:portType name="StockQuoteServicePortType">
<wsdl:operation name="getPriceFile">
<wsdl:input message="axis2:getPriceFileMessage" />
<wsdl:output message="axis2:getPriceFileResponseMessage" />
</wsdl:operation>
<wsdl:operation name="getPrice">
<wsdl:input message="axis2:getPriceMessage" />
<wsdl:output message="axis2:getPriceResponseMessage" />
</wsdl:operation>
<wsdl:operation name="update">
<wsdl:input message="axis2:updateMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteServiceSOAP11Binding" type="axis2:StockQuoteServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="getPriceFile">
<soap:operation soapAction="urn:getPriceFile" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getPrice">
<soap:operation soapAction="urn:getPrice" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap:operation soapAction="urn:update" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceSOAP12Binding" type="axis2:StockQuoteServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="getPriceFile">
<soap12:operation soapAction="urn:getPriceFile" style="document" />
<wsdl:input>
<soap12:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getPrice">
<soap12:operation soapAction="urn:getPrice" style="document" />
<wsdl:input>
<soap12:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap12:operation soapAction="urn:update" style="document" />
<wsdl:input>
<soap12:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuoteServiceSOAP11port" binding="axis2:StockQuoteServiceSOAP11Binding">
<soap:address location="http://localhost:8080/axis2/services/StockQuoteService" />
</wsdl:port>
<wsdl:port name="StockQuoteServiceSOAP12port" binding="axis2:StockQuoteServiceSOAP12Binding">
<soap12:address location="http://localhost:8080/axis2/services/StockQuoteService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<service name="StockQuoteService" scope="application">
<description>
Stock Quote Service
</description>
<operation name="getPriceFile">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
<operation name="getPrice">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
<operation name="update">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
</operation>
<parameter name="ServiceClass">samples.quickstart.service.axiom.StockQuoteService</parameter>
</service>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]