I am trying to use a web service (https/ssl/basicHttpBinding). I add service reference without issues and call it asynchronously. I pass the instance of the client to the CallBack. I get this error when trying to get the result from the service at the CallBack:
Header
http://schemas.xmlsoap.org/ws/2004/08/addressing:Action
for ultimate recipient is required but
not present in the message.
var Result = client.BeginTheServiceOperation(header, CallBack, client);
private static void CallBack(IAsyncResult ar)
{
var client = ar.AsyncState as MyServiceSoapClient;
var result = client.EndTheServiceOperation(ar); // ERROR OCCURS HERE
Console.WriteLine(result);
}
What am I missing?
Thanks
It turns out that the service was expecting SOAP 1.1 and by default WCF uses SOAP 1.2. I needed to create a new custom binding, passing that configuration in and it all worked ok. This pointed me in the right direction: http://social.msdn.microsoft.com/Forums/en/wcf/thread/f3707303-4f35-4079-ac0b-eba4717cada8
This is an indication that you have not applied the the proper message configuration options to your binding. The service is expecting a SOAP message with WS-Addressing headers, but apparently your client is not passing them. Since the default binding would pass them, I have to assume you've changed your binding in some way that would prevent them from being passed.
If more assistance is required, please also add your binding configuration code/config XML to the original post.
Related
I am new to WCF and windows services.
I have wcf service that is called from a class library. I am using that library in Windows service(WS) and this WS subscribes to the services and executes call back methods. The problem here is when I use
wsDualHttpBinding, I get an exception at the highlighted line
subscribe () {
InstanceContext ctx = new InstanceContext(this);
fcsc = new FeatureCreationServiceClient(ctx, "MyEndPoint"); //error
fcsc.Subscribe();
error says
Could not find endpoint element with name 'xx' and contract 'xx' in the ServiceModel client configuration section.
Some of our friends in StackOverFlow suggested replacing wsDualHttpBinding with WShttpBinding. Now the problem is gone but there is new exception saying
Contract requires Duplex, but Binding 'WSHttpBinding' doesn't support it or isn't configured properly to support it.
Please help me. I know that some one might have already asked this question but my search for that was in vain. Thanks in Advance.
I'm new to WCF, but not new to C# and .Net. and am using Visual Studio 2008 and .Net 3.5.
I'm trying to build a Web Service that can receive any inbound Request XML and any namespaces. It would behave like a transparent receiver and simply intake the inbound request XML.
Once I get the request I'm going to pass it to some custom .Net C# Project to invoke a MQPUT to IBM MQ Series.
Right now I have the WCF Web Service Application receiving a generic inbound operation called RunTest(). I consume the WSDL into SoapUI, build a sample request and breakpoint and it works. But, when I try to pass our company request XML it doesn't land on the breakpoint.
Here is the ServiceContract and Operation:
[ServiceContract(Name="IService1",Namespace="cfg-env=http://www.co.com/schemas/cfg- env/")]
//[ServiceContract]
public interface IService1
{
[OperationContract]
void RunTest();
[OperationContract]
void CFX();
Here is the Method for the Operation:
public void RunTest()
{ <<<it does break here using the request from the WSDL
string serviceName;
string queueManager;
string queue;
string requestMessage;
//Capture the Service Name
serviceName = "";
//Save the QueueManager
queueManager = "";
//Save the Request Queue
queue = "";
//Save the Message
requestMessage = "";
//Call MQ Put
Engine eng = new Engine();
try
{
eng.Put(serviceName, queue, requestMessage, queueManager);
}
The main thing I need to do is receive the inbound XML, interogate it for a few pieces of information and call this Method to do the MQPUT function on MQ.
The inbound namespace will look like the above but I'd like to ensure I can receive and interogate any XPATH that may be namespace qualified. If I have to I can work with the cfg-env namespace prefix exclusively as our services do use that as a standard.
What are my key hurdles in doing this in VS 2008 WCF? If you have any links please pass them along if you can.
I believe you specify the name property on the OperationContract attribute as "*" to accept all requests. To make the parameter itself schema agnostic, it should be of type System.ServiceModel.Channels.Message.
What you are building is a "WCF router".
Included in the latest .NET release is a configurable Routing Service.
If the routing service doesn't meet your needs, building your own router is possible but can get really complicated when secure messages are a requirement. This set of MSDN articles is the best resource. They answer your question of how to have a service accept any message, and then continue on into addressing and security issues.
Building a WCF Router, Part 1
Building a WCF Router, Part 2
I'm consuming a WCF service in my project for which I've added the reference using 'Add Service Reference...'. I expected it to generate a clean proxy with a ServiceClient entity and the Interface. Instead, I see that it has created a MethodNameRequest, MethodNameRequestBody, MethodNameResponse, MethodNameResponseBody entities for each OperationContract method.
So while invoking the service methods, the proxy passes to the service method an instance of MethodNameRequest with the input parameters of the method as the properties of the RequestBody. See below an example of a call to AboutInformationGet() method which doesn't accept any parameters.
public WCFDynamicInvocation.PostingService.AboutModel AboutInformationGet() {
WCFDynamicInvocation.PostingService.AboutInformationGetRequest inValue = new WCFDynamicInvocation.PostingService.AboutInformationGetRequest();
inValue.Body = new WCFDynamicInvocation.PostingService.AboutInformationGetRequestBody();
WCFDynamicInvocation.PostingService.AboutInformationGetResponse retVal = ((WCFDynamicInvocation.PostingService.IMIGQPosting)(this)).AboutInformationGet(inValue);
return retVal.Body.AboutInformationGetResult;
}
I believe this behavior is what one would expect to see in a Webservice Proxy. Hence I suspect that the WCF service is not properly configured.
Did someone here face this issue? What would be the change to be done at the service so that the proxy generated is similar to the WCF service.
Cheers.
There is a similar post here.
Right click your service reference -> Configure service reference... -> Check if "Always generate message contracts" check box is checked. Uncheck it and hit OK to regenerate the proxy to see if you get a normal proxy.
After struggling with this for some time, I've finally found that the cause for the message contracts in the proxy was the service interface had the following attribute:
[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document)]
As I understand, I could decorate the DataContracts with the following attribute to avoid wrapping
[MessageContract(IsWrapped = false)]
but the response still gets wrapped as the OperationContract hasn't been modified.
As there were no particular need to use XMLSerializer in place of WCF's default DataContractSerializer, we would remove the XmlSeralizerFormat decoration.
In my WCF service I have implemented a custom encoder which inherits from System.ServiceModel.Channels.MessageEncoder.
In that encoder, I take the raw message and manipulate the received headers in my override of the ReadMessage() method.
During this manipulation, I may sometimes detect something in the header which makes the message invalid, and I want to return a useful exception to the client.
I have tried:
throw new Exception("Some useful message");
And:
throw new FaultException("Some useful message");
They both return an HTTP 400 to the client with no response body.
I can happily throw a FaultException from my actual web service method and this is returned to the client correctly, but at that late stage of the processing I no longer have access to the SOAP headers (unless someone can tell me otherwise).
How can I return a response 500 to the client with a friendly message based on information in the SOAP header?
You can call:
OperationContext.Current.IncomingMessageHeaders
in your service method to inspect the headers there if you wish. A custom MessageEncoder seems to me the wrong beast to be using to do what you describe.
I have the following contract method call in a soap wcf service contract:
[SoapHeader("UserId", typeof(Header), Direction = SoapHeaderDirection.In)]
[OperationContract]
string DeleteVideoRequest(Guid id);
I'm using the wcfextras library to read in a userid header value (or I want to anyways). The problem I'm running into is once I add the soapheader attribute the generated service signature wants a DeleteVideoRequestRequest (made up of the user id and guid id) object instead of a Guid. I'm not sure what is causing this to occur. Is this the expected behavior? I would expect that the signature stay the same, and then you would use the wcfextras code to read the header. Could I be missing something or doing something wrong?
I figured this out. I was missing config values for the extras on the client side.