all groups > dotnet web services > december 2007 >
You're in the

dotnet web services

group:

Calling a WCF service from Non-WCF


Calling a WCF service from Non-WCF Jeronimo Bertran
12/1/2007 9:10:51 PM
dotnet web services:
Hello,

I have a WCF service that I am using to upload files to a server by using
the streamed transfer method. I am currently calling the service from a
WCF client. All I did was add a Service Refrence to my Windows Forms
project using VS2008.

I now want to allow non WCF clients to use the service. How can I do this?

Thanks,

Re: Calling a WCF service from Non-WCF Jeronimo Bertran
12/2/2007 2:33:05 PM
Thanks Tiago. That worked.

I have one question about the WCF templates in VS2008. I created a new
project using the WCF Service Application template. After renaming the
Service, changing the wsHttpBinding to basicHttpBinding and enabling
streamed transfers, the resulting Web Config looks like this:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="FileTransferServicesBinding"
sendTimeout="00:15:00" transferMode="Streamed" messageEncoding="Mtom"
maxReceivedMessageSize="524288000" maxBufferSize="524288000" />
</basicHttpBinding>
</bindings>

<services>
<service name="TransitCommunicationFramework.FileTransferService"
behaviorConfiguration="TransitCommunicationFramework.FileTransferService
Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="FileTransferServicesBinding"
contract="TransitCommunicationFramework.IFileTransferService" >
<!--
Upon deployment, the following identity element should be
removed or replaced to reflect the
identity under which the deployed service runs. If
removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>

</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior
name="TransitCommunicationFramework.FileTransferServiceBehavior">
<!-- To avoid disclosing metadata
information, set the value below to false and remove the metadata
endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in
faults for debugging purposes, set the value below to true. Set to
false before deployment to avoid disclosing exception information -->
<serviceDebug
includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>


Now, from my Client project I use Add Service Reference which I call
FileTransferServiceReference. This produces the following in the
App.config for the client:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileTransferService"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:4039/FileTransferService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFileTransferService"

contract="FileTransferServiceReference.IFileTransferService"
name="BasicHttpBinding_IFileTransferService" />
</client>
</system.serviceModel>


If I run it, it works fine. However I can see that the transferMode is
set to Buffered in the client config. If I manually change it to
Streamed and try runnning it again, I get the following exception:

System.ServiceModel.ActionNotSupportedException: The message with Action
'' cannot be processed at the receiver, due to a ContractFilter mismatch
at the EndpointDispatcher. This may be because of either a contract
mismatch (mismatched Actions between sender and receiver) or a
binding/security mismatch between the sender and the receiver. Check
that sender and receiver have the same contract and the same binding
(including security requirements, e.g. Message, Transport, None).


For sake of completness.. my contract looks looks like the following:

[ServiceContract]
public interface IFileTransferService
{
[OperationContract]
void UploadFile(UploadFileInfo fileInfo);

}


[MessageContract]
public class UploadFileInfo : IDisposable
{
[MessageHeader(MustUnderstand = true)]
public string Filename;

[MessageHeader(MustUnderstand = true)]
public long Length;

[MessageBodyMember(Order = 1)]
public System.IO.Stream FileStream;
Re: Calling a WCF service from Non-WCF Jeronimo Bertran
12/2/2007 2:39:05 PM
Here it is.

<basicHttpBinding>
<binding name="FileTransferServicesBinding" sendTimeout="00:15:00"
transferMode="Streamed" messageEncoding="Mtom"
maxReceivedMessageSize="524288000" maxBufferSize="524288000" />
Re: Calling a WCF service from Non-WCF Tiago Halm
12/2/2007 4:04:31 PM
What is a non WCF client? Assuming its a .NET client not using .NET 3.0 (ex:
limited by Win 2000) then expose a new endpoint with basicHttpBinding. On
the client side, use "Add Web Reference".

Tiago Halm

[quoted text, click to view]

Re: Calling a WCF service from Non-WCF Spam Catcher
12/2/2007 10:07:02 PM
Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam> wrote in
news:Xns99F9D7763E808publicjbbertrancom@207.46.248.16:

[quoted text, click to view]

What type of channel are you using?

I believe non-WCF compatible clients can only talk through web services
Re: Calling a WCF service from Non-WCF Jeronimo Bertran
12/3/2007 9:11:40 AM
It is possible that the clients don't support MTOM. In order to have the
service use MTOM for clients that support it and not use it for those that
don't support it, I assume I need to create aan additional endPoint. How
does the client determine the correct endpoint?


[quoted text, click to view]
Re: Calling a WCF service from Non-WCF Spam Catcher
12/3/2007 1:24:21 PM
Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam> wrote in
news:Xns99FA950A3A673publicjbbertrancom@207.46.248.16:

[quoted text, click to view]

Does your client support MTOM?

If it's regular .NET, you'll need to use WSE 3.0, not sure about Java or
other languages.

--
Re: Calling a WCF service from Non-WCF Spam Catcher
12/3/2007 8:47:11 PM
Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam> wrote in
news:Xns99FB5D88D220Bpublicjbbertrancom@207.46.248.16:

[quoted text, click to view]

In WSE (not WCF) MTOM can be set to an optional mode - if clients support
it, MTOM will be used, if not, MTOM will be disabled.

Not sure if WCF supports this.

--
AddThis Social Bookmark Button