dotnet / dotnet/wcf

Not possible to create Mtom client that has a stream as part of the request object

Open
#4,932 2 comments 0 reactions 1 assignee Claimed by @mconnew View on GitHub
triaged
Dominant language
C#
Stars
1.8k
Forks
576
Avg merge
6d 9h
Merged PRs (30d)
2

Description

**Describe the bug**
A Soap client requires we send them a string ID and a streamed file together. The default service client is currently for a object that takes a string and a byte[].
Ideally, we'd be able to change this so that it takes a string ID and a Stream, and that Stream is turned into the response. However, at the moment we get the error "In order to use Streams with the MessageContract programming model, the type doTransfer must have a single member with MessageBodyMember attribute and the member type must be Stream"

The request looks like this:
```
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="doTransfer", WrapperNamespace="XXX.com/XX/XX/filetransfer", IsWrapped=true)]
public partial class doTransfer
{

[System.ServiceModel.MessageBodyMemberAttribute(Namespace="XXX.com/XX/XX/filetransfer", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string transferId;

[System.ServiceModel.MessageBodyMemberAttribute(Namespace="XXX.com/XX/XX/filetransfer", Order=1)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public Stream fileData;

public doTransfer()
{
}

public doXXX(string stringId, Stream fileData)
{
this.transferId = transferId;
this.fileData = fileData;
}
}
```

**To Reproduce**
Steps to reproduce the behavior:
This is more of a question of "is it even possible at all" - but if this doesn't make sense I can create a sample project

**Expected behavior**
It to work and send the data streamed to the web service

**Additional context**
I can't change the server at all, only the client. It's a java soap web service.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.