How to log XML SOAP messages (Request and Response) to SQL Database? - web-services

In my web application, I need to log all the SOAP messages to my SQL 2005 database whenever I make a web service call to my business partners' web service. How do I accomplish that?
Thanks in Advance,
Tony

You haven't specified what language you are using but assuming C# / .NET you could use SOAP extensions to get the SOAP content as a string and then use a simple INSERT to add to an arbitrary DB table.
There are probably far more elegant methods but I've implemented the above and it works fine.
Just remember to have a large column size in the DB table since the SOAP output could potentially be large.
Note: seems to be a bug in stackoverflow - the URL is:
http://msdn.microsoft.com/en-us/library/esw638yk(VS.71).aspx

Consider using Log4net configured with an Appender that targets the database table.

Related

Nutch or other framework to crawl webservices

I'm looking for a framework what I can use for the following scenario: I have 2 web-services. I call the first service which has json response. In the json response I have some Ids, which I use to call other services and then I merge the services responses and store it in db. I want to call these services every day to update my db.
What I found is Nutch, but it looks like it is a webcrawler for mostly html pages. Is there any framework that I can use for the scenario above? I'm looking for a fault tolerant salable java framework.
Thanks!
You could use Nutch, it is not limited to HTML. If something can be accessed via a URL then Nutch will fetch it, however you might need to implement some custom parsers and indexers to deal with your content.
Alternatively storm-crawler would be both scalable and customisable. You might find it easier to learn than Nutch and more flexible. In your use case you could have one or more queues (e.g. RabbitMQ, AWS SQS, etc...) in front of SC. The seed URLs would be the ones to use on the first service and you could have custom parse filters to generate the URLs for the second one. Finally you'd have a bespoke indexing bolt sending the data to persist to the DB. There's loads of resources available for Storm you could piggy back.
HTH

Does the existence of a .wsdl file mean files must be generated?

When I'm tasked with dealing with connecting to web services, I've always found the appropriate .wsdl file, ran WSDL2Java.bat, and incorporated those Java files into my Java project. Then I've successfully completed my project that needs to access data via web services.
My question is, are there other ways to use the .wsdl file to access web services? ( I'm not talking about creating classes for different languages ). For example, I have documentation describing one company's web services. The examples it shows in it's documentation are essentially dumps of HTTP Post requests. Is this "web services"? It looks to me that the .wsdl file is merely used as a reference to make the correct Post requests. I could just make text templates and plug in the right values, and send them out, right? I really feel like I'm missing something here.
Am I a web-services illiterati?
To call a SOAP web service over HTTP you just need to send it a properly formatted XML with a POST request. That's it! How you build the request is irrelevant as long as it conforms to the SOAP protocol and the payload corresponds to a proper web service operation that exists on the particular web service you are calling.
But how do you know how to build the proper payload?
The web service needs to have some sort of documentation otherwise you don't know what to put inside the XML. The documentation can be whatever you like as long as people can use it to build valid requests. WSDL fits this criteria but has an extra advantage: you can feed it to a tool that generates code. That code knows how to handle all the SOAP details and exposes objects and methods to your application.
What would you prefer? Generating code from the WSDL in a few minutes and be able to call whatever operation on the web service or, build the requests and parse the responses by hand and spend hours or days doing so. What would your boss or company prefer? :)
It looks to me that the .wsdl file is merely used as a reference to make the correct Post requests. I could just make text templates and plug in the right values, and send them out, right?
Right! But you also have to consider your productivity as an employee in one case as opposed to the other.

calling web services from UNIX

I have a requirement to kickoff a workflow which is in salesforce.com thorugh web service from UNIX box. Can any one suggest me options or guide lines to achive this scenario?
I don't think you can just "kick off workflows". You'll have to perform an insert or update of records in Salesforce that will satisfy the workflow's entry criteria.
There's a Java tool called Data Loader for your basic data manipulation activities (you can download it from your own production org)
and it can be scripted for scheduled runs, has config file where you can store user's password in secure way etc. Check out the pdf guide for more ("Command Line Quick Start" chapter)
So I don't think you really need a webservice call...
Unless I misunderstood and you're talking about calling an Apex class' method that has "webservice" keyword and it will somehow perform the updates?
In that case you'll need to download the WSDL file generated for this class (Setup->Develop->Classes) and well, consume it in language of your choice (Java, PHP, Python... this link will help, steps aren't too different), then do your command line magic?
http://wiki.developerforce.com/page/Integration has tons of resources for you :)
Salesforce uses SOAP for their web service. They don't have restful web services now. Just request them to give the wsdl file.
Use this wsdl file to generate the java code. After that get their webService url so that you can proceed with your data pulling
This link may help you..
http://salesforce-walker.blogspot.in/2011/12/to-access-salesforce-data-from-java-we.html
Hope this helps

Fetching remote database info from a client application

What would be the preferred method of pulling content from a remote database?
I don't think that I would want to pull directly from the database for a number of reasons.
(Such as easily being able to change where it is fetching the info from and a current lack of access from outside the server.)
I've been thinking of using HTTP as a proxy to the database basically just using some PHP to display raw text from the database and then grabbing the page and dumping it to a string for displaying.
I'm not exactly sure how I would go about doing that though. (Sockets?)
Right now I am building it around a blog/news type system. Though the content would expand in the future.
I've got a similar problem at the moment, and the approach I'm taking is to communicate from the client app with a database via a SOAP web service.
The beauty of this approach is that on the client side the networking involved consists of a standard HTTP request. Most platforms these days include an API to perform basic HTTP client functions. You'll then also need an XML or JSON parser to parse the returned SOAP data, but they're also readily available.
As a concrete example, a little about my particular project: It's an iPhone app communicating with an Oracle database. I use a web service to read data from the database and send the data to the app formatted in XML using SOAP. The app can use Apple's NSURLConnection API to perform the necessary HTTP request. The XML is then parsed using the NSXMLParser API.
While the above are pretty iPhone-specific (and are Objective-C based) I think the general message still applies - there's tools out there that will do most of the work for you. I can't think of an example of an HTTP API offhand, but for the XML parsing part of the equation there's Xerces, TinyXML, Expat...
HTH!
You might look at using AJAX (I recommend JSON instead of XML though). This is the technology underlying Google Maps.

Using Biztalk orchestration as a webservice

I published an orchestration in Biztalk as a webservice. Does anyone know how I can use XML serialization or something to load XML from a file and "convert" it to the messagetype the webservice expects? How do people usually use this webservices? I try to avoid using untyped messages since I use both XML and flatfile, and have read that it could mean trouble.
Well, I guess generally the idea of web services is that you add a web reference to them, which would generate a set of proxy classes you could use to interact with the web service.
You don't normally have to worry about serialising xml files to and from the web service formats, the generated code will do it for you.
If you do wish to, however, to work of XML, you could use .net serialisation to deserialise an xml file into the generated proxy type (as well as serialise any response you're getting).
Here's a basic example of how to deserialise xml into a class instance, you can then pass this instance into the method in the generated proxy.
System.Xml.Serialization.XmlSerializer xser = new System.Xml.Serialization.XmlSerializer(typeof(<generated request type here>));
xser.UnknownAttribute += new System.Xml.Serialization.XmlAttributeEventHandler(xser_UnknownAttribute);
xser.UnknownElement += new System.Xml.Serialization.XmlElementEventHandler(xser_UnknownElement);
xser.UnknownNode += new System.Xml.Serialization.XmlNodeEventHandler(xser_UnknownNode);
xser.UnreferencedObject += new System.Xml.Serialization.UnreferencedObjectEventHandler(xser_UnreferencedObject);
<generated request type here> request = (<generated request type here>)xser.Deserialize(<xml stream here>);
I hope that makes sense
You question is bit confusing. You started off with saying you published an orchestration as web service, but raised the question about consuming it.
If you are talking about published web service:
The web service generated by BizTalk Web service Wizard is not different from a web service you would have written in .NET. Based on the message type you orchestration is expecting and how your structured the operation in the wizard. The Wizard would have auto generated a webservice for you with WSDL and schemas (there will be some BizTalk specific bits inside, but you don't need to worry about the implementation).
You consumers (independant of platform) should be able to consume that web service without any major issues.
If you are trying to consume a web service from Orchestration
Have a look at this paper http://msdn.microsoft.com/en-us/library/ms935219(BTS.10).aspx