TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ranganath S
NA
1
5k
Problem while adding Web reference of an WCF service
Jul 16 2009 9:42 AM
Hello,
I have written a WCF streamed service for uploading large files. In the service Interface I am taking "stream" as the parameter. The service part of the code is compiling well. When I include this service(Adding Web reference) in the client the same parameter is becoming byte[] and is not taking the FileStream which is supposed to be given to the service which pulls the data from this FileStream. I checked the Reference.cs file on the client side and changed all instances of byte[] to Stream. The code compiles but when run gives exception. Please suggest me how to overcome this problem. Thanks in advance.
My Service Web.config looks like this...
<bindings>
<basicHttpBinding>
<binding
name="FileTransferServicesBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transferMode="Streamed"
messageEncoding="Mtom"
maxBufferSize="65536"
maxReceivedMessageSize="67108864">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SCORMPackageOperation.ServiceImplementation.SCORMFileOperation_Behavior">
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SCORMPackageOperation.ServiceImplementation.SCORMFileOperation_Behavior"
name="SCORMPackageOperation.ServiceImplementation.SCORMFileOperation">
<endpoint binding="basicHttpBinding" bindingNamespace="http://SCORMPackageOperation.ServiceContracts/2009/07"
contract="SCORMPackageOperation.ServiceContracts.ISCORMFileOperation" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
My Message contract is like this...
private Stream inPutField;
[MessageBodyMember(Order = 0)]
public Stream inPut
{
get { return inPutField; }
set { inPutField = value; }
}
My Service Contract is like this....
[OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = true, AsyncPattern = false, Action = "SCORMData")]
void SCORMData(Stream inPut);
Please suggest me what changes I need to do.
My service Implementation is...
public void SCORMData(Stream inPut)
{
FileStream targetStream = null;
Stream sourceStream = inPut;
string uploadFolder = @"C:\S3File\temp\";
string filename = "testSCORMFile";
string filePath = Path.Combine(uploadFolder, filename);
using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
//read from the input stream in 4K chunks
//and save to output stream
const int bufferLen = 4096;
byte[] buffer = new byte[bufferLen];
int count = 0;
long bytesRead = 0;
while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
{
targetStream.Write(buffer, 0, count);
bytesRead += count;
}
targetStream.Close();
sourceStream.Close();
return;
}
}
Regards,
Excel
Reply
Answers (
0
)
Compile a Web Service without visual studio IDE
Application using Webservices being blocked