I have written a SOAP WSDL application using mobilefirst by:
1) Using the Discover backend services option
2) Writing my own JavaScript adapter code to follow the documentation provided by IBM.
Now my final R&D is to consume this soap service using a java adapter.
I have gone through many StackOverflow topics and samples but I haven't been able to find anything related. Can anyone explain the steps to invoke a SOAP-based webservice request using java adapter?
The following video blog post details the following about Java adapers: https://www.youtube.com/watch?v=cKM5480-6wI
Creating Java Adapter
Understanding Java Adapter structure
Implementing simple sayHello procedure for HTTP GET method
Implementing several procedures for different HTTP methods
Working with various types of request parameters
Using Java code to access MobileFirst server functionality and Java servlet functionality
Debugging Java Adapters
Communicating with a simple backend using using Apache HTTP Client
Leveraging WSDL files and communicating with a SOAP based webservice
Using WLResourceRequest in client applications to communicate with Java Adapters
Using Postman REST client for communicating with Java Adapters
Create HTTP Adapter
In xml add WebService Host and Port in Domain/Port elements
Assemble soapXMLRequest
Use HTTP Invoke to call server
ex.
var input = {
method : 'post',
returnedContentType : 'xml',
headers : {
SOAPAction : SOAP_FULL_URL
},
path : WEBSERVICE_PATH,
body : {
content : soapXMLRequest,
contentType : 'text/xml; charset=utf-8'
}
};
var response = WL.Server.invokeHttp(input);
Related
Currently i working on Creating WCF service in order to communicate xamarin forms (Android) with sqlserver. For that i have tried some examples from the following link https://developer.xamarin.com/guides/xamarin-forms/web-services/consuming/wcf/ but it was not working also it throws error(SystemError).
My goal : i have to retrieve data from sqlserver using WCF service . Kindly provide ideas to solve this issues.
Thanks.
krupa
i think you want to create web-service, you can learn how to make wcf from here
webservices is same like an other client-server architecture where you send request to server and get response.
now make one hello world webservices base on above example
Request - in request you have to send data you can use xml or json
in method of webservice you have to process your data [calculate/store in DB/etc]
in response you send response data back
*to test a webservice use postman extension in chrome browser
I'm writing an UWP app in C#, and I'm trying to have it consume data from a (pre-existing) WCF service. I can't find any information online on the subject. Here is what my code looks like (WCF service is Serv, service namespace is Ns):
var config = Ns.ServClient.EndpointConfiguration.BasicHttpBinding_IServ;
var client = new Ns.ServClient(config);
var result = client.TestCall();
I get the following exception, which I don't understand how to parse:
Exception thrown:
'System.ServiceModel.Security.MessageSecurityException' in
mscorlib.ni.dll
Additional information: The HTTP request is unauthorized with client
authentication scheme 'Negotiate'. The authentication header received
from the server was 'Negotiate, NTLM'.
What does this error message mean? And how do I successfully authenticate with the WCF service?
Bonus question: what is the ServiceReferences.Designer.ClientConfig file? How do I use it?
I opened the Package.appxmanifest file and added the Enterprise Authentication and Private Networks (Client & Server) capabilities. This fixed the issue.
Trying to identify worklight adapter requests from web server access logs, but all the requests look really generic. Any idea how to identify adapter requests?
The Request only contains "POST /Worklight/apps/services/api/MobileApp/android/query HTTP 1.1". I
can't see the adapter name nor procedure name.
while this query is indeed an adapter invocation , the adapter name, method and parameters are embedded into the POST HTTP message body. its not a big payload (less than 1KB).
I'm not an IHS log expert, but maybe there is a way to log also message body.
( I saw this un-answered: https://stackoverflow.com/questions/27354942)
However, if you upgrade to newer MFP version (v7.0+) then you can expose adapters as a RESTfull service. This will make the IHS logs much more clear which adapter was called (each one has different URL).
Is there any API to invoke a Java adapter from a HTTP adapter in IBM MobileFirst Platform Foundation 7.0?
I have tried with WL.Server.invokeHttp(input), but received a 404 response. What should be the value for 'path' in the input?
It is currently not possible to directly call a Java adapter from a JavaScript adapter.
You are encouraged to submit a feature request: https://developer.ibm.com/mobilefirstplatform/help
Alternatives:
Implement a JavaScript adapter that invokes Java code. See the tutorial Using Java in JavaScript adapters
Use another JavaScript adater - set the Java adapter as the backend it connects to and call it from the requesting JavaScript adapter
Rough steps to follow:
You have JavaScript adapter A
This adapter calls a procedure in another JavaScript adapter, adapter B (adapter mashup)
JavaScript adapter B will set in its XML the Java adapter properties as the backend (localhost, MFP server port)
Requests from this adapter should then be sent to /the-server-context-root/adapters/the-java-adapter/*
The Java adapter should have its security disabled, otherwise an access token would need to be forwarded in an header from the client in the request
As you can see the second option is less trivial to implement, and is less supported. I would investigate option 1...
I have been going through the book "Learning WCF" trying to get my head around creating and using WCF web services. The first part of the book walks the reader through creating and then consuming a simple "Hello World" web service.
The problem I am having is that the client application seems to have no know the structure of the WCF Interface when calling it. How can this be necessary if a web service could be called from any number of programming languages?
I have listed the relevant example code below ...
Here is the code for the Interface
[ServiceContract(Namespace="http: //www.thatindigogirl.com/samples/2006/06")]
public interface IHelloIndigoService
{
[OperationContract]
string HelloIndigo();
}
Here is the code for the Service that hosts the web service
static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService) ,
new Uri("http: //localhost: 8000/HelloIndigo")))
{
host. AddServiceEndpoint(typeof(HelloIndigo. IHelloIndigoService) ,
new BasicHttpBinding(), "HelloIndigoService");
host. Open( );
Console. WriteLine("Press <ENTER> to terminate the service host") ;
Console. ReadLine();
}
}
Here is the code for the client app that consumes the WCF service
This is where I get confused. Since this client application could be any language capable of calling a web service why is there a necessity of knowing the definition of the interface?
using System. ServiceModel;
[ServiceContract(Namespace = "http: //www.thatindigogirl.com/samples/2006/06")]
public interface IHelloIndigoService
{
[OperationContract]
string HelloIndigo( );
}
static void Main(string[ ] args)
{
EndpointAddress ep = new
EndpointAddress("http: //localhost: 8000/HelloIndigo/HelloIndigoService") ;
IHelloIndigoService proxy = ChannelFactory<IHelloIndigoService>.
CreateChannel(new BasicHttpBinding(), ep);
string s = proxy. HelloIndigo();
Console. WriteLine(s) ;
Console. WriteLine("Press <ENTER> to terminate Client.") ;
Console. ReadLine();
}
Am I missing an important point here? Perhaps my understanding of what is needed to consume a web is lacking. My goal is to be able to use WCF to create a .NET service that could be called from any programming language or environment.
Might anyone suggest a good tutorial on creating "cross platform consumable" web services from within .NET? Thanks!
This approach is based on shared interface (the book acutally does not share the interface but instead it uses local copy) and is successfully applied in environment where both client and server are written in .NET. This approach is not usable for interoperability or SOA solutions.
Other approach uses metadata exposed by the service. Metadata are defined as WSDL document plus several XSD documents. These metadata files are way to provide information about your service to both .NET and non .NET developers. The book contains definition of Metadata (mex) endpoint so you will definitely read about that.
Using metadata in .NET means creating service proxy. You can do it automatically using Visual studio's Add service reference or command line utility svcutil.exe. Anyway generated proxy code will probably still contain the interface created from metadata. It is used to create transparent abstraction of the service for the client.
'The interface' doesn't mean a .NET interface file, it means the more general programming interface - a set of objects with properties, and methods with parameters. This is also called the service contract.
The reason that the client and the service need to share (i.e. both know about) the interface is simple when you think about it - if the client doesn't know the interface, how do they know what operations are available and what the expected request/response objects should look like?
Every WCF service is composed of
A - address
B - binding
C - contract
The contract is declared using an interface on the serverside. It declares which methods are available to the client. If you are using a http binding you can invoke a service operation by issuing a http request (using a http client in any library or language - or even a web browser) pointed at the correct address. So the client does not need any interface reference at all. It just needs to follow the ABC of the service.
Here is a nice blog on WCF and Java interopability.
To answer your question on how to develop 'cross platform consumable' web services, consider the REST approach. Making REST-style web services truly makes them independent of the platform that consumes them. Simply put, they use the already well established HTTP protocols everything supports: GET and POST Http methods.
You could then have a Java app simply make POST calls to your WCF services with your own custom XML content in the payload without having to fiddle with more complex stuff like making SOAP wrappers and the like. Check out Rob Bagby's article on REST:
http://www.robbagby.com/rest/rest-in-wcf-part-i-rest-overview/