Call 3rd party webservice Options
kennethm
Posted: Monday, March 03, 2008 11:06:01 PM
Rank: Enthusiast

Joined: 9/4/2007
Posts: 13
I read this in the forum.

"You can integrate your 3rd party webservice / db and do data presenation with no limitations with xslt"

How do I do that, and what options do I have when I want to call a 3rd party webservice?

In what different ways can I do it?

/Kenneth
drobar
Posted: Tuesday, March 04, 2008 1:15:13 AM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,256
Location: KY, USA
Hi, Kenneth,

Looks like you saw that in this post... http://forum.umbraco.org/misc/umbraco-screenshots---which-one-would-you-pick.

Maybe Per can clarify more, but I think he was saying that umbraco doesn't limit you in any way and you can not only work with data that resides within umbraco, but also with data that is external to umbraco.

You can get to external data with custom usercontrols, xslt extensions, REST calls using /base, RSS-type feeds using built-in commands like umbraco.library:GetDocumentByUrl() in your xslt macros, etc.

Depending on what you want to accomplish, you'll find one or more of these options the most capable.

Tell us more about what you're trying to accomplish and we'll try to guide you to the best solution for your situation.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
kennethm
Posted: Tuesday, March 04, 2008 9:48:18 AM
Rank: Enthusiast

Joined: 9/4/2007
Posts: 13
Thanks for the reply!

The webservices are rather simple.

One is for listing company names and another is for display calendar information.
kennethm
Posted: Tuesday, March 04, 2008 8:57:48 PM
Rank: Enthusiast

Joined: 9/4/2007
Posts: 13
I would love to see some short example of umbraco.library:GetDocumentByUrl(). Can't find anything about it.
drobar
Posted: Tuesday, March 04, 2008 9:21:36 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,256
Location: KY, USA
Hi, Kenneth,

Here are a couple of examples...

Display Images from Flickr:
http://kasperb.dk/2006/6/26/display-your-flickr-images-on-your-umbraco-driven-website.aspx

Twitter Package:
http://www.creativewebspecialist.co.uk/2008/02/19/twitter-umbraco-package/

Pick up Atom feeds:
http://forum.umbraco.org/17056

Hope this helps.

cheers,
doug.


MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
kennethm
Posted: Tuesday, March 04, 2008 11:47:59 PM
Rank: Enthusiast

Joined: 9/4/2007
Posts: 13
Thanks for the examples. Looks good. I will need it later!

In this case I want to call an WSDL webservice though. Is it possible?

Is the following link something that can be used?

http://code.google.com/p/wsdl-viewer/
kenny
Posted: Wednesday, March 05, 2008 6:12:24 AM

Rank: Aficionado

Joined: 8/12/2006
Posts: 129
Location: Norway
WSDL Viewer is just a tool to visualize WSDL files in a more user friendly way.

I'd use GetXmlDocumentByUrl when calling POX (plain old xml) / REST services. Web Services on the other hand needs some .NET coding. Here's your options:

- XSLT Extension. This is a .NET library that expose functions in your XSLT.
- .NET User Controls / Custom Controls (As Umbraco Macros or Data Types)
- Umbraco BASE. A REST API feature in Umbraco and is .NET libraries returning XML mapped to URLs. See configuration file for details. (GetXmlDocumentByUrl -> Umbraco BASE).


Kenneth Solberg - core dev - level 2 cert pro - my blog
kennethm
Posted: Wednesday, March 05, 2008 11:22:20 PM
Rank: Enthusiast

Joined: 9/4/2007
Posts: 13
Thank you for all the replies. I have now solved it in a way I think works and I would like to share my solution to others.

The problem was to call a webservice I made in .NET. Here's the step to make it work:

1. On you .NET App add the following in you web.config. The important thing here is the "HttpGet". I removed Soap only for security issues.:

Code:
<system.web>
    <webServices>
    <protocols>
       <remove name="AnyHttpSoap"/>
       <remove name="Unknown"/>
           <add name="HttpGet"/>
    </protocols>
    </webServices>
</system.web>


2. Try to access you webservice in a browser using the following url. The result should be plain old xml code:

http://www.mydomain.com/webservices/MyWebservice.asmx/MyFunction

3. Ok. So far so good. Now to the fun part. To be able to get this information into your application you'll use XSLT. Here's an example code:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
        xmlns:w="http://www.mydomain.com"
    exclude-result-prefixes="msxml umbraco.library">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:variable name="url" select="/macro/url" />
<xsl:variable name="xml" select="umbraco.library:GetXmlDocumentByUrl($url)" />


<xsl:template match="/">
   <xsl:apply-templates select="$xml/w:myTag/w:myOtherTag"/>
</xsl:template>


<xsl:template match="w:myOtherTag">
   <xsl:value-of select="w:SomeValue"/>
</xsl:template>

</xsl:stylesheet>


Take a look at the following link if you don't understand the url thing in the beginning.
http://kasperb.dk/2006/6/26/display-your-flickr-images-on-your-umbraco-driven-website.aspx

The important thing here is the namespace thing. Without declaring your own namespace nothing will work.


Hopes it helps someone.






Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.