Error WSE012 (Action Missing) when consuming WSE webservice - vb.net

For a small project I need to use (consume) an external (secure) webservice.
This webservice uses SOAP1.2 protocol with WSE extention (username + password)
I use VB (VS2008) and added the Service Reference, customized the app.config to use wsHttpBinding rather than basicHttpBinding
One of the public Functions of the webservice is called
searchByName(String, String)As System.Xml.XmlElement
In code I first initialize the security;
wsTST.ClientCredentials.UserName.UserName = "mycompanyname"
wsTST.ClientCredentials.UserName.Password = "abc%2011!"
and then call the Function (the code fails here):
Debug.WriteLine(wsTST.searchByName("John", "Johnson"))
A first chance exception of type 'System.ServiceModel.FaultException' occurred in mscorlib.dll.
Error message:
WSE012: The input was not a valid SOAP message because the following information is missing: action.
Can anyone tell me if consuming a WSE webservice is possible from VB.NET2008?
And can anyone point me in the right direction?
I have searched for hours, but could not find any relevant information.
Regards, Frank

Related

in WCF service can callback be made using wsHttpbinding?

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.

Exception handler in a WCF REST service

I would like to create an exception handler in a WCF REST service. For Client recesse this exception in a simple way. I found many implementations using SOAP IErrorHandler for WCF, but none for REST. Could anyone help me with this?
Did you try using WebFaultException?
the exception information is provided in response message. Usually (in HTTP GET for REST), a result is expected as XML/JSON. In case of any error the error message is places instead of REST URI result.
http://www.robbagby.com/rest/effective-error-handling-with-wcf-rest/
WCF Rest Error Handling
IErrorHandler also works for WCF REST services, although you may need to know about how a non-SOAP (e.g., JSON) message is mapped inside the WCF Message object. The example at http://blogs.msdn.com/b/carlosfigueira/archive/2011/06/07/wcf-extensibility-ierrorhandler.aspx shows an error handler used to format responses to a JS client (in JSON).

Calling WCF Service with no input parameters in BizTalk Orchestration

I am trying to call an IIS hosted WCF web service that simply returns the current date from a BizTalk orchestration. There are no input parameters to this service.
Please ignore the First Receive_1 and the Last Send_1 shapes as I just used them to get started with this orchestration. My Orchestration looks like:
I used the "Add Generated Items..." wizard to add the generated reference to the web service in the Orchestration. My web service definition looks like:
[ServiceContract]
public interface ICalculator
{
[OperationContract]
DateTime GetLastExecutionDate();
}
public class CalculatorService : ICalculator
{
public DateTime GetLastExecutionDate()
{
return DateTime.Now.AddMonths(-6);
}
}
After I added the generated reference to the BizTalk project, the wizard created a set of ports and Multi Part Messages like below:
I have also created local messages to transport data between these calls like below:
Now, I have read everywhere I could that I will need to construct the InputMessage in order to call a web service with no parameters.
Some forums/website say that I need to simply created a blank ConstructMessage shape with the MessageType of dateRequest Message. While doing so the project doesn't compile and I get the following error message:
And the other suggested item is to do a MessageAssignment for a blank Document. So the MessageAssginment shape in my Orchestration has the following:
xDoc = new System.Xml.XmlDocument();
xDoc.LoadXml("<GetLastExecutionDate/>");
dateRequest.parameters = xDoc;
While this compiles and get's deployed, my BizTalk instance get's suspended with the following exception:
There was a failure executing the send pipeline:
"Microsoft.BizTalk.DefaultPipelines.XMLTransmit,
Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" Source: "XML assembler" Send Port:
"REDACTED_1.0.0.0_REDACTED.ExportData_WCFPort_dace989afd9cd9c5"
URI: "http://localhost/COMPANYNAME/WCFService/Service.svc" Reason: This
Assembler cannot retrieve a document specification using this type:
"GetLastExecutionDate".
And the parameter data passed into the service is:
So my question is: How do I call a WCF Service that does not expect any input parameters.
Go to your service request message schema file from within visual studio.
Right click -> Generate Instance.
Grab the XML instance generated and replace all the double quotes with single quotes.
Then paste this into your LoadXml() in your assignment
You probably need an XML namespace in the string used in the message assignment shape. I suggest you validate your XML string against the web service schema to make sure it makes a valid message.
You could also use xsd.exe to create .NET classes from your web service schema.
See http://msdn.microsoft.com/en-us/library/aa547985(BTS.20).aspx for a complete list of ways to contruct a message in an orchestration.
You use the XMLTransmit pipeline and there could be multiple root causes for it throwing error message
"Reason: This Assembler cannot retrieve a document specification using this type: xxx"
The most likely cause is that you do not have a schema deployed matching the message you are transmitting.
But the good news is that there is no need for the XMLTransmit pipeline in this scenario. Just change the send-pipeline to PassThruTransmit and it will most likely solve at least that problem.

How does WCF Decide which Operation to Dispatch To?

I'm building a WCF SOAP application. The WSDL file has numerous operations of which many have the same argument type. The WSDL file defines all soapAction attributes as "''". When I try to start such a service WCF throw an exception saying that soapActions have to be unique.
After some googling I'm even more puzzled than before. I used SOAPUI to create a mock service with two operations which take the same input type and without the soapActions defined it always chooses the same operation. When the actions are defined it works fine.
My questions are:
Can you make a WCF SOAP service without unique soapActions (actually leaving the soapActions "''" as defined in the original WSDL)?
How can a service choose the right operation without the soapAction defined?
Edited:
I'm not in control of the WSDL. I'm using the WSCF.Blue tool to create a service stub from the WSDL file. I might be able to modify the WSDL, but I want to see if there is some possibility to leave it as it is.
It is not very clear from your question but I suggest you are building service based on some defined WSDL, aren't you? WCF by default uses SOAP action because it is required part of WS-I Basic Profile 1.1 offered by WCF services with BasicHttpBinding. WSDLs with empty SOAP actions are used when the action is defined by root body element.
WCF samples provides example of custom DispatchOperationSelector which is able to route messages to operations by their root body element. This is probably what you need to add to your service so that clients based on provided WSDL can call it.

View underlying SOAP message using vb.net

I have a VB.NET web service that calls a third party web service. How can I view the SOAP message generated by .NET before it is sent to the third party web service and how can I see the SOAP response before it is serialized by .NET.
When creating a standalone EXE, I see the Reference.vb file that is automatically generated, but don't see a similar file when my project is a web service. I have found lots of C# code to do this, but none in VB.NET.
Edit - Fiddler and TCP loggers are great, but will not work for my purposes. I need to be able to access the raw SOAP messages from within the application so I can log them or modify them. I need to do more than just see the messages going back and forth.
You can use fiddler or a tcp sniffer to filter and identify all outgoing and incoming traffic on your host.
This is if you want to see the xml request and response.
How about using an extension to allow you to examine the SOAP message?
Accessing Raw SOAP Messages in ASP.NET Web Services
http://msdn.microsoft.com/en-us/magazine/cc188761.aspx
I was trying to do the same thing and this seems to work for me:
Dim message As String = OperationContext.Current.RequestContext.RequestMessage.ToString()
I didn't think it would be that easy since most of the time ToString() returns the name of the class, but I tried it out and low and behold.
I know you asked this back in January so if since then you've figured out a better way let me know.
Please note that if you're catching the exception in a class that implements IErrorHandler then you have to perform this operation from within the ProvideFault() method instead of the HandleError() method because the context is closed before it gets to call the HandleError() method.
Hope this helps.