How to pass parameter to soap web service using webservice consumer in anypoint - anypoint-studio

Can anyone give me an example how we can pass parameter to webservice if we are using ws:consumer in Anypoint Studio.
<ws:consumer config-ref="Web_Service_Consumer1" operation="login" doc:name="Web Service Consumer"/>
i have to pass object parameter to login method of web service as we do it in java
LoginParam lp = new LoginParam("key","pwd");
LoginResponseParam lrp = port.login(lp);

Related

WCF client works as console application but running as Windows service, fails with EndpointNotFoundException

I wrote a C# console application to consume a local WCF service using NetNamedPipeBinding. The WCF service I consume is running as a local Windows application. My WCF client works fine as a console application. However, when I implement essentially the same WCF client not as a console application but as a Windows service, my WCF client cannot find the local WCF endpoint and throws System.ServiceModel.EndpointNotFoundException exceptions.
Why would a WCF client run fine as a console application and then throw EndpointNotFoundException when the client is running as a Windows service?
This is how I create the channel factory in the client code:
// Define some local variables needed to create the channel factory
string strendpoint = string.Format("net.pipe://localhost/{0}", BluehillAPIService.ServiceName);
EndpointAddress endpoint = new EndpointAddress(strendpoint);
NetNamedPipeBinding binding = new NetNamedPipeBinding();
InstanceContext instanceContact = new InstanceContext(this);
// Create the channel factory
ChannelFactory = new DuplexChannelFactory<IBluehillAPIService>(instanceContact, binding, endpoint);
Then I create the channel like this:
_bluehillAPIService = ChannelFactory.CreateChannel();
No errors so far, but when I try to actually use the channel as follows, I get an exception:
if (!_bluehillAPIService.APIHeartbeat()) ...
The call to _bluehillAPIService.APIHeartbeat() in my WCF client generates a System.ServiceModel.EndpointNotFoundException when this code is running as a Windows service logged in as Local System but works fine when essentially identical code is running as a console application.
Because the LocalSystem account presents anonymous credentials when accessing network resources, network applications running in that context may not operate as expected.
Specify an appropriate account on your service's "Log On" tab -- an account where you can log in and run the application without error:

How to pass values to SOAP service using web service consumer?

Hello i have an soap service , in which a method will receive 2 input values and gives a bool O/P.
i am using web service consumer endpoint to consume this soap service. i want to understand what is the way i can send values to SOAP service .
`<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://.....?singleWsdl" service="ClientService" port="WSHttpBinding_IClientService" serviceAddress="http://....../ClientService.svc" doc:name="Web Service Consumer"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="AuthenticateUser" doc:name="Web Service Consumer"/>
The web service consumer is very tipically used in conjunction with DataMapper, with it datamapper can pretty much visually construct a request for you. Given that DataMapper is an EE feature and you don't mention you have a license I suggest you changing approach and rather use the CXF module.
Based of the web service consumer documentation, the consumer is expecting the xml request of the service operation.
My quick suggestion is to use any tool to build the xml request based on the wsdl (such as SOAP UI) and use it in a set-payload, using MEL expressions to inject the two parameter values.
Hope it helps.
Please go through to get a better understanding on ws:consumer :- http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer+Reference and http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer
also there is an example in github:- https://github.com/mulesoft/mule-tooling-examples/blob/master/web-service-consumer/src/main/app/tshirt-service-consumer.xml
You can use <stdio:inbound-endpoint system="IN" doc:name="STDIO"/> to pass values to the service .. But I am not sure if it is a recommended approach ..
Another option is set-payload you can try to pass the value to the service
You can try this with this example
<ws:consumer-config name="Web_Service_Consumer"
wsdlLocation="somelocation_1.0.wsdl"
service="GreeterResponderService" port="GreeterResponderPort"
serviceAddress="http://user:password#localhost:8088/mockbinding"
doc:name="Web Service Consumer"/>

WCF Web Service Call Using SOAP 1.1

I'm attempting to call a web service from a VB .NET 3.5 Win Forms application. I have been able to create a Service Reference but when I call the web service I receive the SOAP fault:
A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
The web service uses username and password authentication with a certificate. I also need to connect to different URLs depending on the environment (development or production). For these reasons I was attempting to use a WSHttpBinding created in code. However, it appears that type of binding assumes SOAP 1.2. I've been told by the author of the web service that they are unable to support SOAP 1.2.
Is there a way, either with the WSHttpBinding or a CustomBinding in code, to consume a web service that only supports SOAP 1.1 using a WCF Service Reference?
Dim binding As New System.ServiceModel.WSHttpBinding
binding.Security.Mode = ServiceModel.SecurityMode.Transport
binding.Security.Transport.ClientCredentialType = ServiceModel.HttpClientCredentialType.Basic
Dim service As New ServiceReference.ServiceClient(binding, New System.ServiceModel.EndpointAddress(baseUrl))
service.ClientCredentials.UserName.UserName = serviceUsername
service.ClientCredentials.UserName.Password = servicePassword
Any help is appreciated!

consuming WCF service in .net 2.0 windows application

I'm new in WCF service and I need to consume the WCF service from my client for my current .net 2.0 windows app. I successfully added the WCF service as web reference in my .net 2.0 application but when using the web method of the service it took long time to execute the method and in the end my application is not responding. Base on the request in fiddler, the request has been timed out. My client provides me a user name and password but I don't know where to use it. Base on the wcf web service wsdl of my client, it uses WSHttpBinding.
I also created a sample .net 4.0 windows application and added the service as reference but still cannot use the web method. I check also the request in fiddler and gives me a response error "The request for security token could not be satisfied because authentication failed.".
Please help. I need to consume the WCF service using my existing .net 2.0 application.
Thank you very much in advance!
If you want to consume your WCF service from .NET 2.0 via adding web reference you must use BasicHttpBinding - that is only backward compatible build-in binding (except custom defined binding) with ASMX based client.
Your exception in case of .NET 4.0 test complains about security token - WsHttpBinding uses Windows security by default. It is hard to diagnose the problem further because you didn't provide enough information.

Consume WCF Service Hosted in a Windows Service

I wrote the WCF Service and hosted in windows service. I need to know how to consume this windows service in my client application.
Note:
I wrote Net pipe binding service.
Edit:
How can I write the client application for net pipe binding?
You need to do a few easy steps:
start your Windows service hosting your WCF service
from within Visual Studio (2008 or higher), right-click on a project node in the solution explorer and choose "Add service reference"
enter the URL where your service can be reached
That's about all there is, really. Visual Studio will go to your running service, get all the metadata it needs (assuming you've enabled a MEX endpoint for metadata exchange), and will create a client proxy class for you to use to connect your client to your service.
Marc
you need to use ChannelFactory to create a proxy, and then you can use the proxy to perform wcf tasks.
ChannelFactory<IWCFService> pipeFactory = new ChannelFactory<IWCFService>(
new NetNamedPipeBinding(),
new EndpointAddress("net.pipe://localhost/PipeWCFService"));
IWCFService pipeProxy = pipeFactory.CreateChannel();
pipeProxy.RunWCFServiceMethod();}
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
You can consume it like any other WCF service. The method used for hosting the WCF service is not relevant to the client side.
If you need details on how to actually build the client, let me know and i'll update the post.
Edit : Start here to learn how to build a WCF client.