SOAP Mashup with Bing search

In this post I’ll create a Mashup with the DataListPanel. Data will be retreived from the Bing search web service. Then I’ll format the result in the list with a datatemplate, a clickable uri and use the the Open event to launch a web page and I show you how to show a clickable Uri. The Open Event is available in Lawson Smart Office 10.0.1.

Prereq: In order to use the Bing search API (for testing) you need to register and get your own application ID as identifier. In my Mashup this ID is replaced with “BingApplicationID”. Register to get your ApplicationID

The final mashup will look like this:

Start by adding the DataListPanel to your mashup. Select Data Service “WS” and press the configure button.

Select the operation you would like to run and save.

Now the configuration looks like this:

Add a search field and hook up the events.

The final result is a list with columns that bind to the data returned from the Web Service.

Use the tool://wstest or the configuration tool in the Designer to investigate what kind of data is returned. I took some time to ficure out what parameters had to be sent to do a simple we search with this web service. There are lots of different ways that you can search.

The Uri is displayed with the following template:

<Grid.Resources>
 <DataTemplate x:Key="templateLink">
       <TextBlock>
         <ui:TaskHyperlink Foreground="Black" NavigateUri="{Binding Path=Url}">
             <TextBlock Text="{Binding Path=Url}" />
          </ui:TaskHyperlink>
       </TextBlock>
   </DataTemplate>
  </Grid.Resources>

The ui namespace is defined as: xmlns:ui=”clr-namespace:Mango.UI.Controls;assembly=Mango.UI”. TaskHyperlink is useful when you whant to have links that launch other applications, such as mforms, mashups or web content.

Here is the complete XAML, just remeber to put in your ApplicationID.

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI">
<Grid.Resources>
 <DataTemplate x:Key="templateLink">
         <TextBlock>
            <ui:TaskHyperlink Foreground="Black" NavigateUri="{Binding Path=Url}">
               <TextBlock Text="{Binding Path=Url}" />
            </ui:TaskHyperlink>
         </TextBlock>
   </DataTemplate>
  </Grid.Resources>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
     <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>
  <StackPanel Orientation="Horizontal"><TextBlock Text="Bing for:" VerticalAlignment="center" /><TextBox Name="searchText" Width="200" />
  <Button Content="Search" IsDefault="True" Style="{DynamicResource styleButtonPrimaryMashup}">
      <Button.CommandParameter>
        <mashup:Events>
          <mashup:Event TargetName="searchControl" SourceEventName="Click" TargetEventName="Get">
            <mashup:Parameter TargetKey="parameters.Query" Value="{Binding ElementName=searchText, Path=Text}" />
          </mashup:Event>
        </mashup:Events>
      </Button.CommandParameter>
    </Button></StackPanel>
  <mashup:DataListPanel Grid.Row="1" Name="searchControl">
    <mashup:DataListPanel.Events>
      <mashup:Events>
        <mashup:Event SourceEventName="Open" LinkUri="{Binding SelectedItem.Url, ElementName=ListView}">
        </mashup:Event>
      </mashup:Events>
    </mashup:DataListPanel.Events>
    <mashup:DataListPanel.DataService>
      <mashup:DataService Type="WS">
        <mashup:DataService.Operations>
          <mashup:DataOperation Name="Get">
            <mashup:DataParameter Key="WS.Wsdl" Value="http://api.search.live.net/search.wsdl" />
            <mashup:DataParameter Key="WS.Address" Value="http://api.search.live.net/soap.asmx" />
            <mashup:DataParameter Key="WS.Operation" Value="Search" />
            <mashup:DataParameter Key="WS.Contract" Value="BingPortType" />
            <mashup:DataParameter Key="parameters.Query" Value="Kista" />
<!--You need to register and get your own id on order to run the web service-->
            <mashup:DataParameter Key="parameters.AppId" Value="BingApplicationID" />
            <mashup:DataParameter Key="parameters.Sources." Value="Web" />
          </mashup:DataOperation>
        </mashup:DataService.Operations>
      </mashup:DataService>
    </mashup:DataListPanel.DataService>
    <ListView Name="ListView" Margin="8" ItemsSource="{Binding Web.Results}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
      <ListView.View>
        <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
          <GridView.Columns>
            <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Title}" />
            <GridViewColumn Header="Description" DisplayMemberBinding="{Binding Description}" />
            <GridViewColumn Header="Url" CellTemplate="{StaticResource templateLink}" />
          </GridView.Columns>
        </GridView>
      </ListView.View>
    </ListView>

  </mashup:DataListPanel>
  <ui:StatusBar Name="StatusBar" Grid.Row="2" Grid.Column="0" />

</Grid>

Now, I would probably not have this result in a columned view like this but in a nice list.

3 thoughts on “SOAP Mashup with Bing search

  1. erez

    What I have to do with the mashup is activate two screens:

    1.Source screen
    Source screen Display list of customers by LISTPANEL

    2. Target screen
    Target screen to display data by SQL query with DataListPanel.

    My problem is that I can not make the data display for example:

    I will select a customer from the Source screen and I expect the data to be presented on Target screen in a direct continuation from Source screen.

    Thanks

    Note:

    I can run both screens but no option of direct contact

    Reply
    1. erez

      Further to my question

      From Mashup Designer I want to know how to set up parameters so that a specific operation can be performed when we use Web Service in a Mashup.

      I succeed to run the Web Service in a Mashup but fails to define specific parameters on Mashup Designer.

      Reply
      1. karinpb Post author

        Hi,
        Are you using a template as SOAP input or passing parameters to the DataListPanel?
        Is the event for current item changed configured on the source panel? Do you see the expected source value when turning on the debug window?
        Have you viewed the post here: https://smartofficeblog.com/2012/01/05/calling-a-web-service-using-ws-and-rest-data-services/.

        Generally it is impossible to give development support via the blog when it comes to calling web services as they could look very different.

        Use the toos://wstest and check the input parameter names and configure those in the event that will trigger the target call to list the data? If there is no call at all (eg not error) the event from source to target is not triggered and you need to check that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s