I'm trying to create a WCF service (.Net 4.5 in VS2012) for file uploads that can be consumed by clients in other languages, Java (using CXF) in particular. I've got the WCF side of things working great from .Net clients, but am having some issues on the
CXF side.
I'm not sure if this is a WCF or CXF issue so I'm posting here and the CXF mailing lists to see if I'm doing something wrong on one side or the other.
When I try to generate the proxy in CXF from the WSDL through Eclipse (4.2/Juno), I'm getting an exception that prevents the proxy from being created:
<ServiceContract()>
Public Interface IUploadFile
<OperationContract()>
Sub UploadFile(ByVal remoteFile As RemoteFile)
<OperationContract()>
Function DownloadFile() As RemoteFile
End Interface
My WCF message contract (RemoteFile) is as follows:
<MessageContract()> _
Public Class RemoteFile
Implements IDisposable
<MessageHeader(MustUnderstand:=True)> _
Public FileName As String
<MessageHeader(MustUnderstand:=True)> _
Public Length As Long
<MessageBodyMember(Order:=1)> _
Public FileByteStream As System.IO.Stream
Public Sub Dispose() Implements IDisposable.Dispose
If FileByteStream IsNot Nothing Then
FileByteStream.Close()
FileByteStream = Nothing
End If
End Sub
End Class
Obviously the exception indicates it is having an issue creating the stream body type of the message, but does anyone see what I'm doing wrong or need to change to be able to enable non-.Net clients to use this WCF service?
Hi, please check if you have configure the wcf service properly. Below article introduce some requirement to your application to allow java clients consuming wcf services.
That's a good article that I hadn't seen before, thanks. I double checked everything he does against mine and unfortunately I'm still having the same issue. I've been trying out all sorts of settings on my service the past few days and haven't had any luck
or change in behavior.
Okay, here's more info that will hopefully help. Everything I'm seeing online related to the "
Cannot resolve the name 'xxxxxxx' to a(n) 'type definition' component.
" error indicates an issue with the WSDL namespaces, so I've been poking around more in the generated WSDL and changing things on the code side to see the result.
My particular message says it can't resolve
'ns0:StreamBody'
so I referenced my main WSDL. My class "RemoteFile" is not defined directly in the WSDL, so it is imported with these statements:
Cool, there's my mapping for the Stream parameter that is the cause of the exception. However, none of this looks problematic so I'm still somewhat stumped. I've tried using the new ?singleWsdl feature in 4.5 and the flattened WSDL it creates has the same
issue.
So, I'm still stumped at this point. If anyone has some insight, I'd love to hear it.
Another followup, I managed to get the CXF client generated but now I'm encountering an http 400: Bad Request coming back from WCF when the CXF client tries to upload the file. Digging into the WCF traces, there's an exception being thrown:
System.ServiceModel.CommunicationException: Error creating a reader for the MTOM message ---> System.Xml.XmlException: MIME part with Content-ID '<root.message@cxf.apache.org>' not found.
Based on the error message on the server, the XOP starting header is missing but my interceptor on the CXF side shows it is there:
I implemented the exact same service in a clean project with a byte array instead of a Stream object and I get the exact same error message:
Error creating a reader for the MTOM message ---> System.Xml.XmlException: MIME part with Content-ID '<root.message@cxf.apache.org>' not found.
Regardless of whether the WCF service uses a Stream object or byte array, the CXF clients still use Java byte arrays.
kettch19
Member
38 Points
91 Posts
WCF file upload/download issue from Java client
Nov 01, 2012 02:18 AM|LINK
I'm trying to create a WCF service (.Net 4.5 in VS2012) for file uploads that can be consumed by clients in other languages, Java (using CXF) in particular. I've got the WCF side of things working great from .Net clients, but am having some issues on the CXF side.
I'm not sure if this is a WCF or CXF issue so I'm posting here and the CXF mailing lists to see if I'm doing something wrong on one side or the other.
When I try to generate the proxy in CXF from the WSDL through Eclipse (4.2/Juno), I'm getting an exception that prevents the proxy from being created:
My WCF service contract is as follows:
<ServiceContract()> Public Interface IUploadFile <OperationContract()> Sub UploadFile(ByVal remoteFile As RemoteFile) <OperationContract()> Function DownloadFile() As RemoteFile End InterfaceMy WCF message contract (RemoteFile) is as follows:
<MessageContract()> _ Public Class RemoteFile Implements IDisposable <MessageHeader(MustUnderstand:=True)> _ Public FileName As String <MessageHeader(MustUnderstand:=True)> _ Public Length As Long <MessageBodyMember(Order:=1)> _ Public FileByteStream As System.IO.Stream Public Sub Dispose() Implements IDisposable.Dispose If FileByteStream IsNot Nothing Then FileByteStream.Close() FileByteStream = Nothing End If End Sub End ClassMy WCF service configuration is as follows:
... <system.serviceModel> <bindings> <basicHttpBinding> <binding name="FileTransferServicesBinding" transferMode="Streamed" messageEncoding="Mtom" maxReceivedMessageSize="10067108864"> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration="UploadServiceBehavior" name="Server.UploadFile"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="FileTransferServicesBinding" contract="Server.IUploadFile" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="UploadServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> ...My WSDL is as follows:
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions name="UploadFile" targetNamespace="http://tempuri.org/"> <wsp:Policy wsu:Id="BasicHttpBinding_IUploadFile_policy"> <wsp:ExactlyOne> <wsp:All> <wsoma:OptimizedMimeSerialization/> </wsp:All> </wsp:ExactlyOne> </wsp:Policy> <wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="http://localhost:10186/UploadFile.svc?xsd=xsd1" namespace="http://tempuri.org/"/> <xsd:import schemaLocation="http://localhost:10186/UploadFile.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/Message"/> <xsd:import schemaLocation="http://localhost:10186/UploadFile.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> </xsd:schema> </wsdl:types> <wsdl:message name="RemoteFile"> <wsdl:part name="parameters" element="tns:RemoteFile"/> </wsdl:message> <wsdl:message name="RemoteFile_Headers"> <wsdl:part name="FileName" element="tns:FileName"/> <wsdl:part name="Length" element="tns:Length"/> </wsdl:message> <wsdl:message name="IUploadFile_DownloadFile_InputMessage"/> <wsdl:portType name="IUploadFile"> <wsdl:operation name="UploadFile"> <wsdl:input wsaw:Action="http://tempuri.org/IUploadFile/UploadFile" name="RemoteFile" message="tns:RemoteFile"/> </wsdl:operation> <wsdl:operation name="DownloadFile"> <wsdl:input wsaw:Action="http://tempuri.org/IUploadFile/DownloadFile" message="tns:IUploadFile_DownloadFile_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/IUploadFile/DownloadFileResponse" name="RemoteFile" message="tns:RemoteFile"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="BasicHttpBinding_IUploadFile" type="tns:IUploadFile"> <wsp:PolicyReference URI="#BasicHttpBinding_IUploadFile_policy"/> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="UploadFile"> <soap:operation soapAction="http://tempuri.org/IUploadFile/UploadFile" style="document"/> <wsdl:input name="RemoteFile"> <soap:header message="tns:RemoteFile_Headers" part="FileName" use="literal"/> <soap:header message="tns:RemoteFile_Headers" part="Length" use="literal"/> <soap:body use="literal"/> </wsdl:input> </wsdl:operation> <wsdl:operation name="DownloadFile"> <soap:operation soapAction="http://tempuri.org/IUploadFile/DownloadFile" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="RemoteFile"> <soap:header message="tns:RemoteFile_Headers" part="FileName" use="literal"/> <soap:header message="tns:RemoteFile_Headers" part="Length" use="literal"/> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="UploadFile"> <wsdl:port name="BasicHttpBinding_IUploadFile" binding="tns:BasicHttpBinding_IUploadFile"> <soap:address location="http://localhost:10186/UploadFile.svc"/> </wsdl:port> </wsdl:service> </wsdl:definitions>Obviously the exception indicates it is having an issue creating the stream body type of the message, but does anyone see what I'm doing wrong or need to change to be able to enable non-.Net clients to use this WCF service?
Nico_He
Member
114 Points
27 Posts
Re: WCF file upload/download issue from Java client
Nov 02, 2012 08:11 AM|LINK
Hi, please check if you have configure the wcf service properly. Below article introduce some requirement to your application to allow java clients consuming wcf services.
http://hoonzis.blogspot.com/2011/07/consuming-wcf-services-with-java-client.html
kettch19
Member
38 Points
91 Posts
Re: WCF file upload/download issue from Java client
Nov 04, 2012 05:24 AM|LINK
That's a good article that I hadn't seen before, thanks. I double checked everything he does against mine and unfortunately I'm still having the same issue. I've been trying out all sorts of settings on my service the past few days and haven't had any luck or change in behavior.
kettch19
Member
38 Points
91 Posts
Re: WCF file upload/download issue from Java client
Nov 05, 2012 02:42 AM|LINK
Okay, here's more info that will hopefully help. Everything I'm seeing online related to the "
" error indicates an issue with the WSDL namespaces, so I've been poking around more in the generated WSDL and changing things on the code side to see the result.My particular message says it can't resolve
'ns0:StreamBody'so I referenced my main WSDL. My class "RemoteFile" is not defined directly in the WSDL, so it is imported with these statements:So, here is the schema definition of the one at "xsd1":
<xs:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> <xs:import schemaLocation="http://localhost:10186/UploadFile.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/Message"/> <xs:element name="RemoteFile"> <xs:complexType> <xs:sequence> <xs:element name="FileByteStream" type="q1:StreamBody"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="FileName" nillable="true" type="xs:string"/> <xs:element name="Length" type="xs:long"/> </xs:schema>So far so good, here's my mapping to my "RemoteFile" class. Now, one more import to get the mapping for the import at "xsd0":
<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/Message"> <xs:simpleType name="StreamBody"> <xs:restriction base="xs:base64Binary"/> </xs:simpleType> </xs:schema>Cool, there's my mapping for the Stream parameter that is the cause of the exception. However, none of this looks problematic so I'm still somewhat stumped. I've tried using the new ?singleWsdl feature in 4.5 and the flattened WSDL it creates has the same issue.
So, I'm still stumped at this point. If anyone has some insight, I'd love to hear it.
kettch19
Member
38 Points
91 Posts
Re: WCF file upload/download issue from Java client
Nov 08, 2012 02:44 PM|LINK
Another followup, I managed to get the CXF client generated but now I'm encountering an http 400: Bad Request coming back from WCF when the CXF client tries to upload the file. Digging into the WCF traces, there's an exception being thrown:
System.ServiceModel.CommunicationException: Error creating a reader for the MTOM message ---> System.Xml.XmlException: MIME part with Content-ID '<root.message@cxf.apache.org>' not found.
Based on the error message on the server, the XOP starting header is missing but my interceptor on the CXF side shows it is there:
--uuid:70dd56ae-7102-45c9-a5d9-b0078ad6ad13
a5d9-b0078ad6ad13
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ...
</soap:Envelope>
--uuid:70dd56ae-7102-45c9-
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <4e2a3954-d8ec-490d-a844-ab55594e9c80-1@tempuri.org>
...file content here...
Any ideas? As far as I can tell all of the content-type declarations are what WCF expects...
kettch19
Member
38 Points
91 Posts
Re: WCF file upload/download issue from Java client
Nov 14, 2012 01:18 AM|LINK
I implemented the exact same service in a clean project with a byte array instead of a Stream object and I get the exact same error message:
Regardless of whether the WCF service uses a Stream object or byte array, the CXF clients still use Java byte arrays.
I'm at a loss here...