Hi,
I'm trying to call a .Net WCF Service from an Axis2 java client on Windows.
Simple calls to the service are working, but I have problems with
a stream returned by one of the methods (see "Exception" below).
The client stub was created with Axis' wsdl2java tool.
I hope somebody can tell me what the problem is and how to fix it...
TIA
Andreas
Exception:
=======================================
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException:
ParseError at [row,col]:[1,288]
Message: elementGetText() function expects text only elment but
START_ELEMENT was encountered.
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
at org.tempuri.FileTransferStub.fromOM(FileTransferStub.java:1377)
at
org.tempuri.FileTransferStub.CheckOutDocument(FileTransferStub.java:874)
at DmsClient.DmsClient.buttonDownloadMouseClicked(DmsClient.java:525)
...
Caused by: org.apache.axiom.om.impl.exception.OMStreamingException:
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,288]
Message: elementGetText() function expects text only elment but
START_ELEMENT was encountered.
at
org.apache.axiom.om.impl.llom.OMStAXWrapper.getElementText(OMStAXWrapper.java:847)
at
org.tempuri.FileTransferStub$StreamBody$Factory.parse(FileTransferStub.java:2872)
at
org.tempuri.FileTransferStub$CheckOutDocumentResponse$Factory.parse(FileTransferStub.java:11169)
at org.tempuri.FileTransferStub.fromOM(FileTransferStub.java:1306)
... 25 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,288]
Message: elementGetText() function expects text only elment but
START_ELEMENT was encountered.
at
com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getElementText(Unknown
Source)
at
org.apache.axiom.om.impl.llom.OMStAXWrapper.getElementText(OMStAXWrapper.java:845)
... 28 more
=======================================
WCF Service interface:
=======================================
[ServiceContract( Namespace = "http://www.dummy.de/DmsService" )]
public interface IFileTransfer
{
[OperationContract]
[FaultContract( typeof( ServiceOperationFailedException ) )]
Stream CheckOutDocument( string id );
}
=======================================
Service configuration:
=======================================
<binding name="BasicHttpStreaming"
maxBufferSize="1000000"
maxReceivedMessageSize="500000000"
messageEncoding="Mtom"
transferMode="StreamedResponse" >
<readerQuotas maxArrayLength="500000000" />
</binding>
<service name="DmsBatchFileTransfer.FileTransfer"
behaviorConfiguration="DmsDocumentServiceBehavior">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpStreaming"
contract="dummy.Profile.DmsService.IFileTransfer"
name="BasicHttpFileTransfer" >
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://ntfe:8013/DmsBatch/FileTransfer/" />
</baseAddresses>
</host>
</service>
<behavior name="DmsDocumentServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
=======================================
WSDL:
=======================================
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="FileTransfer"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:tns="http://tempuri.org/"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:i0="http://www.dummy.de/DmsService"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
<wsp:Policy wsu:Id="BasicHttpFileTransfer_policy">
<wsp:ExactlyOne>
<wsp:All>
<wsoma:OptimizedMimeSerialization
xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:import namespace="http://www.dummy.de/DmsService"
location="http://ntfe:8013/DmsBatch/FileTransfer/?wsdl=wsdl0" />
<wsdl:types />
<wsdl:binding name="BasicHttpFileTransfer" type="i0:IFileTransfer">
<wsp:PolicyReference URI="#BasicHttpFileTransfer_policy" />
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="CheckOutDocument">
<soap:operation
soapAction="http://www.dummy.de/DmsService/IFileTransfer/CheckOutDocument"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceOperationFailedExceptionFault">
<soap:fault name="ServiceOperationFailedExceptionFault" use="literal" />
</wsdl:fault>
<wsdl:fault name="ServiceOperationFailedRetryExceptionFault">
<soap:fault name="ServiceOperationFailedRetryExceptionFault"
use="literal" />
</wsdl:fault>
<wsdl:fault name="AuthenticationExceptionFault">
<soap:fault name="AuthenticationExceptionFault" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FileTransfer">
<wsdl:port name="BasicHttpFileTransfer" binding="tns:BasicHttpFileTransfer">
<soap:address location="http://ntfe:8013/DmsBatch/FileTransfer/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
=======================================
Axis2 Client stub generated by wsdl2java:
=======================================
// ...
_serviceClient.getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE );
// ...
private java.lang.Object fromOM(org.apache.axiom.om.OMElement param,
java.lang.Class type, java.util.Map extraNamespaces)
throws org.apache.axis2.AxisFault {
try {
if (org.tempuri.FileTransferStub.CheckOutDocument.class.equals(type)) {
return org.tempuri.FileTransferStub.CheckOutDocument.Factory
.parse(param.getXMLStreamReaderWithoutCaching());
}
if (org.tempuri.FileTransferStub.CheckOutDocumentResponse.class.equals(
type)) {
// Exception is thrown here...
return org.tempuri.FileTransferStub.CheckOutDocumentResponse.Factory
.parse(param.getXMLStreamReaderWithoutCaching());
}
// ...
} catch (java.lang.Exception e) {
throw org.apache.axis2.AxisFault.makeFault(e);
}
return null;
}
public org.tempuri.FileTransferStub.CheckOutDocumentResponse CheckOutDocument(
org.tempuri.FileTransferStub.CheckOutDocument checkOutDocument4)
throws java.rmi.RemoteException,
org.tempuri.IFileTransfer_ServiceOperationFailedExceptionFault_FaultMessage,
org.tempuri.IFileTransfer_AuthenticationExceptionFault_FaultMessage,
org.tempuri.IFileTransfer_ServiceOperationFailedRetryExceptionFault_FaultMessage
{
try {
org.apache.axis2.client.OperationClient _operationClient =
_serviceClient.createClient(_operations[2].getName());
_operationClient.getOptions()
.setAction("http://www.dummy.de/DmsService/IFileTransfer/CheckOutDocument");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient,
org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
"&");
// create a message context
org.apache.axis2.context.MessageContext _messageContext =
new org.apache.axis2.context.MessageContext();
// create SOAP envelope with that payload
org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(getFactory(_operationClient.getOptions()
.getSoapVersionURI()),
checkOutDocument4,
optimizeContent(
new javax.xml.namespace.QName("http://tempuri.org/",
"CheckOutDocument")));
//adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
// set the message context with that soap envelope
_messageContext.setEnvelope(env);
// add the message contxt to the operation client
_operationClient.addMessageContext(_messageContext);
//execute the operation client
_operationClient.execute(true);
org.apache.axis2.context.MessageContext _returnMessageContext =
_operationClient.getMessageContext(
org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
org.apache.axiom.soap.SOAPEnvelope _returnEnv =
_returnMessageContext.getEnvelope();
// Call to fromOM returns Exception...
java.lang.Object object = fromOM(_returnEnv.getBody()
.getFirstElement(),
org.tempuri.FileTransferStub.CheckOutDocumentResponse.class,
getEnvelopeNamespaces(_returnEnv));
_messageContext.getTransportOut().getSender()
.cleanup(_messageContext);
return (org.tempuri.FileTransferStub.CheckOutDocumentResponse) object;
} catch (org.apache.axis2.AxisFault f) {
org.apache.axiom.om.OMElement faultElt = f.getDetail();
// ...
}
}
======================================
End of Mail. ;-)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]