XSL1.0 excluding previous nodes - xslt-1.0

I'm constrained to vanilla XSLT1.0 (no extensions) and MSXML transforms
Completely stumped on a problem.
I have an XML that I need to create HTML output from. Nodes need to be sorted by version_code then by despatch_tape_colour, BUT then grouped by address_line_1 (easier to look at image below to see: cream colored headings are group headers)
<order>
<order_no>16292</order_no>
<job_no>16292</job_no>
<loads>
<LoadID>10</LoadID>
<load_seq>10</load_seq>
<load_address_1>731 Fraser Street</load_address_1>
<load_haulier>Purolator</load_haulier>
<load_splits>
<load_split_id>10</load_split_id>
<load_split_description>Prince Rupert Northern View</load_split_description>
<version_code>Z1</version_code>
<despatch_tape_colour>FLAT</despatch_tape_colour>
</load_splits>
</loads>
<loads>
<LoadID>11</LoadID>
<load_seq>11</load_seq>
<load_address_1>8506 Main Street</load_address_1>
<load_haulier>Purolator</load_haulier>
<load_splits>
<load_split_id>11</load_split_id>
<load_split_description>*</load_split_description>
<version_code>Z1</version_code>
<despatch_tape_colour>FLAT</despatch_tape_colour>
</load_splits>
</loads>
<loads>
<LoadID>19</LoadID>
<load_seq>19</load_seq>
<load_address_1>130 - 766 Cliveden Place</load_address_1>
<load_haulier>Purolator</load_haulier>
<load_splits>
<load_split_id>19</load_split_id>
<load_split_description>*</load_split_description>
<version_code>Z1</version_code>
<despatch_tape_colour>FLAT</despatch_tape_colour>
</load_splits>
</loads>
<loads>
<LoadID>123</LoadID>
<load_seq>123</load_seq>
<load_address_1>100 Railway Avenue West</load_address_1>
<load_haulier>Purolator</load_haulier>
<load_splits>
<load_split_id>123</load_split_id>
<load_split_description>*</load_split_description>
<version_code>Z2</version_code>
<despatch_tape_colour>FLAT</despatch_tape_colour>
</load_splits>
</loads>
<loads>
<LoadID>124</LoadID>
<load_seq>124</load_seq>
<load_address_1>130 - 766 Cliveden Place</load_address_1>
<load_haulier>Purolator</load_haulier>
<load_splits>
<load_split_id>124</load_split_id>
<load_split_description>*</load_split_description>
<version_code>Z2</version_code>
<despatch_tape_colour>FLAT</despatch_tape_colour>
</load_splits>
</loads>
</order>
In the image below you can see that 19 and 124 are grouped together as they both have same address_line_1 (it's required that 19 appears in the order it does). The problem is that node 124 then appears later and is again grouped with 19. What I need to do is ignore load_split_ids that have already been iterated over or included in a previous group.
The only other way I can think of (maybe :-)) solving it is to create and msxml nodeset and then iterate over that, but I'd like to see if there's an alternative method
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html"/>
<xsl:variable name="template_version">1.0.0.26</xsl:variable>
<xsl:variable name="template_date">7th August 2016</xsl:variable>
<!-- Based on Shipments v1.0.0.8 -->
<xsl:variable name="currency_symbol"/>
<xsl:key name="unique_load_addresses_version_format" match="/order/loads[starts-with(load_haulier, 'Purolator')]/load_splits" use="concat(../load_address_1,'_',version_code,'_',despatch_tape_colour)"/>
<xsl:include href="Globals_pdf.xsl"/>
<xsl:template match="order">
<html>
<head>
<!-- PrinceXML: Adding UTF-8 stops browser interpreting   as A-circumflex followed by a <space> -->
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"/>
<style type="text/css">
body {font-family: Verdana, Arial, Helvetica, sans-serif; font-size:8pt;}
h1 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 22pt; font-weight: bold; margin: 0 0 10px 0;}
.outer { width: 100%; }
.tax { width: 100%;}
table {font-family: Verdana, Arial, Helvetica, sans-serif;cellspacing: 0px; cellpadding: 0px; border-width: 0; border-collapse: collapse; border-spacing: 0px; width: 100%; }
td {vertical-align: top; font-family: Verdana, Arial, Helvetica, sans-serif; padding: 5px 1px 5px 1px; font-size: 8pt; border-width: 1pt; border-style: solid; border-color: <xsl:value-of select="$color2"/>; }
th {text-align: left; vertical-align: bottom; background-color: LightSteelBlue; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; padding: 5px 1px 5px 1px; border-width: 1pt; border-style: solid; border-color: <xsl:value-of select="$color2"/>; border-collapse: collapse; border-spacing: 0px; color: black;}
.bold { font-weight: bold; }
.grey {background-color: #dddddd; }
.proforma { color: black; }
.heading { vertical-align: bottom; text-align: center;}
.bottom_center { vertical-align: bottom; text-align: center; }
.top_center { vertical-align: top; text-align: center; }
.top_left { vertical-align: top; text-align: left; }
.middle_left { vertical-align: middle; text-align: left; }
.middle_center { vertical-align: middle; text-align: center; }
.top_right { vertical-align: top; text-align: right; }
.bottom_left { vertical-align: bottom; text-align: left; }
.bottom_right { vertical-align: bottom; text-align: right; }
.left_indent {padding-left: 70px;}
.top_indent {padding-top: 35px;}
.label {font-weight: bold; width: 15%; padding-top: 2px; padding-bottom: 2px; padding-right: 5px; text-align: right; width: 30%; font-size: 12pt;}
.contents {padding-left: 5mm; width: 30%; padding-top: 2px; padding-bottom: 2px; width: 70%; font-size: 12pt;}
hr {border: none; background-color: black; height: 0.5pt;}
.first_row { border-top: 2pt solid red; }
.red {color: #aa0000; }
</style>
</head>
<body>
<table class="loads" style="">
<tr>
<th>S/P/I</th>
<th>Zone</th>
<th>Format</th>
<th>Address</th>
<th>Carrier</th>
</tr>
<xsl:for-each select="/order/loads[starts-with(load_haulier, 'Purolator')]/load_splits[generate-id() = generate-id(key('unique_load_addresses_version_format', concat(../load_address_1,'_',version_code,'_',despatch_tape_colour))[1])]">
<xsl:sort select="concat(version_code,'_',despatch_tape_colour)" data-type="text" />
<xsl:variable name="curr_address" select="../load_address_1"/>
<tr>
<td style="background-color: #fdf5e6; color: blue; border-top: 2px solid grey">Load/LoadSplitID: <xsl:value-of select="../LoadID"/>/<xsl:value-of select="load_split_id"/></td>
<td style="background-color: #fdf5e6; color: blue; border-top: 2px solid grey"><xsl:value-of select="version_code"/></td>
<td style="background-color: #fdf5e6; color: blue; border-top: 2px solid grey"><xsl:value-of select="despatch_tape_colour"/></td>
<td style="background-color: #fdf5e6; color: blue; border-top: 2px solid grey"><xsl:value-of select="../load_address_1"/></td>
<td style="background-color: #fdf5e6; color: blue; border-top: 2px solid grey"></td>
</tr>
<xsl:for-each select="/order/loads[starts-with(load_haulier, 'Purolator') and load_address_1 = $curr_address]/load_splits">
<xsl:sort select="concat(version_code,'_',despatch_tape_colour)" data-type="text" order="ascending" />
<xsl:variable name="part_ref" select="load_despatch_code"/>
<xsl:variable name="line_type">
<xsl:choose>
<xsl:when test="position() = 1">S</xsl:when>
<xsl:otherwise>P</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr>
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="position()=1">color: red; border-top: 2px solid black</xsl:when>
<xsl:when test="position()=last()">color: black;</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="load_split_id"/>
</td>
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="position()=1">color: red; border-top: 2px solid black</xsl:when>
<xsl:when test="position()=last()">color: black;</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="version_code"/>
</td>
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="position()=1">color: red; border-top: 2px solid black</xsl:when>
<xsl:when test="position()=last()">color: black;</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="despatch_tape_colour"/>
</td>
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="position()=1">color: red; border-top: 2px solid black</xsl:when>
<xsl:when test="position()=last()">color: black;</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="../load_address_1"/>
</td>
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="position()=1">color: red; border-top: 2px solid black</xsl:when>
<xsl:when test="position()=last()">color: black;</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="../load_haulier"/>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
Any XSL wizards, got any suggestions?
TIA
Mark

Related

Am I not properly performing update(goal)?

I am building an app in Vue that is tracking the sum of donations paid to my ExtraLife Team and tallies them up based on a user-submitted #tag in the message provided with the donation. Currently, I've been working on a Goal Editor view using what I've named the adminView component to display the full goals table and allow a user to edit the rows. The problem that I'm having is that for some reason when I attempt to update(goal) I'm getting a 400 (Bad Request) response. Obviously, I must have something malformed or missing in the data, I'm just not seeing what.
Here is my current #/components/AdminView.vue (Auth url and Key Removed)
<template>
<div id="adminView">
<h1>Goal Editor</h1>
<table style="border-collapse: collapse; width: 80%">
<thead>
<tr style="border: 1px solid #ddd">
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 3%;
"
>
ID
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 5%;
"
>
Tag
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 35%;
"
>
Description
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 10%;
"
>
Target Amount
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 10%;
"
>
Current Donations
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 4%;
"
>
Active
</th>
<th
style="
padding: 8px;
text-align: left;
border: 1px solid #ddd;
width: 6%;
"
></th>
</tr>
</thead>
<tbody>
<tr
v-for="(goal, index) in goals"
:key="goal.goal_id"
:style="[index % 2 == 0 ? 'background-color: #f2f2f2' : '']"
>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
{{ goal.goal_id }}
</td>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
<input
v-model="goal.tag"
v-if="goal.editing"
type="text"
style="border: none; outline: none; width: 100%"
/>
<span v-else>#{{ goal.tag }}</span>
</td>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
<input
v-model="goal.goal_description"
v-if="goal.editing"
type="text"
style="border: none; outline: none; width: 100%"
/>
<span v-else>{{ goal.goal_description }}</span>
</td>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
<input
v-model="goal.goal_target"
v-if="goal.editing"
type="number"
style="border: none; outline: none; width: 100%"
/>
<span v-else>${{ goal.goal_target }}</span>
</td>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
<input
v-model="goal.goal_tally"
v-if="goal.editing"
type="number"
style="border: none; outline: none; width: 100%"
/>
<span v-else>${{ goal.goal_tally }}</span>
</td>
<td style="padding: 8px; text-align: left; border: 1px solid #ddd">
<input
v-model="goal.active"
v-if="goal.editing"
type="checkbox"
style="outline: none"
/>
<span v-else>{{ goal.active }}</span>
</td>
<td style="padding: 8px; text-align: center; border: 1px solid #ddd">
<button
v-if="goal.editing"
#click="saveGoal(goal)"
style="
outline: none;
border: none;
background-color: #4caf50;
color: white;
padding: 8px 16px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
"
>
Save
</button>
<button
v-else
#click="editGoal(goal)"
style="
outline: none;
border: none;
background-color: #f2f2f2;
color: black;
padding: 8px 16px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
"
>
Edit
</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { createClient } from "#supabase/supabase-js"; // Import the Supabase client
export default {
name: "adminView",
data() {
return {
supabase: null,
session: null,
error: null,
goals: [],
};
},
async created() {
// Create the Supabase client object
this.supabase = createClient(
"MY DB URL IS HERE",
"MY DB SECRET KEY IS HERE"
);
// Fetch the current user's session
const { data, error } = await this.supabase.auth.getSession();
this.session = data;
this.error = error;
// Fetch the goals from the database
await this.fetchGoals();
},
methods: {
async fetchGoals() {
console.log("Fetching goals...");
const { data, error } = await this.supabase.from("goals").select("*");
console.log(data, error);
this.goals = data;
console.log("Goals fetched!");
console.log(this.goals);
},
editGoal(goal) {
goal.editing = true;
},
async saveGoal(goal) {
console.log(goal);
goal.editing = false;
await this.supabase.from("goals").update(goal);
},
},
};
</script>
<style>
#adminView {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
Thanks to a comment from #kissu I remembered to check the network tab and compared it to a manual request and discovered that I had an extra value in this.goal that was making it's way into the request. I fixed by deleting the extra value and then setting it back to false.
async saveGoal(goal) {
delete goal.editing;
console.log(goal);
await this.supabase
.from("goals")
.update(goal)
.eq("goal_id", goal.goal_id);
goal.editing = false;
},

VB NET user control panel doesn't show up

I'm not a vb net master, and I got some problem I still can't solve.
I have a main page, when I click on a button I want to display a panel (a web user control I imported in the main page) but it shows nothing.
I think I've done some stupid mistake but I can't get out of it.
Let me show you some code:
This is the user control:
<asp:Panel ID="MainPanelUserMessage" runat="server" Height="278px" Style="z-index: 100; left: 0px;
position: absolute; top: 0px; background-position: center center; background-attachment: fixed; background-repeat: repeat; font-size: 12px; font-family: Tahoma;" Width="746px">
<asp:Label ID="LabelTitoloMex" runat="server" Style="font-weight: bold; font-size: 14px;
z-index: 100; left: 0px; color: #ffffff; font-family: Verdana, Tahoma; position: absolute;
top: 0px; background-color: #000000; text-align: center" Text="Messaggio dal supporto tecnico"
Width="746px"></asp:Label>
<asp:Label ID="LabelOggettoMex" runat="server" Style="font-weight: bold; font-size: 12px;
z-index: 105; left: 7px; color: #424242; font-family: Tahoma, Verdana; position: absolute;
top: 30px" Text="Oggetto:"></asp:Label>
<asp:TextBox ID="TextOggettoUser" runat="server" MaxLength="100" Style="font-size: 12px;
z-index: 106; left: 68px; font-family: Tahoma, Verdana; position: absolute; top: 30px;
text-align: left" ToolTip="Oggetto" Width="660px" ReadOnly="True"></asp:TextBox>
<asp:TextBox ID="TextMessaggioUser" runat="server" Height="160px" MaxLength="2000" Style="font-size: 12px;
z-index: 107; left: 9px; font-family: Tahoma, Verdana; position: absolute; top: 60px;
text-align: left" TextMode="MultiLine" ToolTip="Messaggio" Width="721px"
ReadOnly="True"></asp:TextBox>
<asp:Button ID="okButton" runat="server" Style="font-size: 12px;
font-family: Tahoma, Verdana; text-align: left" CssClass="style1"
Text="Chiudi"> </asp:Button>
<input id="cbxRemember" type="checkbox" class="style2" />
<asp:Label ID="lblRemember" runat="server" Style="font-weight: bold; font-size: 12px;
color: #424242; font-family: Tahoma, Verdana; "
Text="Non mostrare più questo messaggio." CssClass="style3"></asp:Label>
</asp:Panel>
In the page it will contain the panel it autogenerated this:
Protected WithEvents MessaggioUtente1 As Global.System.Web.UI.WebControls.Panel
When i click the button this is the code that is executed:
PanelClientEnabled = False //this works and obfuscates background
UserMessage1.Visible = True
But the panel doesn't show up.
Any hint?

CSS/HTML - How to set inner padding inside input?

When I try to set a padding it's not center anymore. It moves to the other side.
How can I set padding of the textbox input so that it's still aligned center?
table {
text-align: right;
}
#textfield {
float: left;
}
.textbox {
font-family: Arial, Helvetica, sans-serif;
background: rgba(255, 255, 255, 0.44);
color: #333;
border: 1px solid #A4A4A4;
padding-left: 5px;
line-height: 1;
width: 225px;
height: 18px;
border-spacing: 8px;
}
<table width="450" border="1" cellspacing="3" cellpadding="3">
<tbody>
<tr>
<td width="225"><label>First Name:</label></td>
<td width="225">
<input class="textbox" type="text" name="textfield" id="textfield">
</td>
</tr>
</tbody>
</table>
You can try adding
.textbox {
box-sizing: border-box;
}
table {
text-align: right;
}
#textfield {
float: left;
}
.textbox {
font-family: Arial, Helvetica, sans-serif;
background: rgba(255, 255, 255, 0.44);
color: #333;
border: 1px solid #A4A4A4;
padding-left: 5px;
line-height: 1;
width: 225px;
height: 18px;
border-spacing: 8px;
box-sizing: border-box;
}
<table width="450" border="1" cellspacing="3" cellpadding="3">
<tbody>
<tr>
<td width="225"><label>First Name:</label></td>
<td width="225">
<input class="textbox" type="text" name="textfield" id="textfield">
</td>
</tr>
</tbody>
</table>

Can't remove line at top of html table

I'm building a site that includes a table in the middle of the homepage, and I can't seem to get a line (looks like an <hr> line) to disappear from the top of it. Here's a link to the page http://marccary.com/test and here's the code I'm using for the table:
<table cellspacing="0" cellpadding="0" border="none">
<colgroup border="none">
<col span="1" width="400" >
<col span="1" width="400" >
</colgroup>
<tr>
<td height="225" width="600"><p align="center">
<iframe width="400" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F84936057%3Fsecret_token%3Ds-4zQJw&show_artwork=true&secret_url=true"></iframe><br><span style="font-size:20px;">Marc Cary on Soundcloud>></span></p></td>
<td height="225" width="600"><p align="center">
<iframe width="400" height="225" src="http://www.youtube.com/embed/j9GhIaaEC6c" frameborder="0" allowfullscreen></iframe>
<span style="font-size:20px;">Marc Cary's YouTube channel>></savaipan></p></td></tr></table>
I've gone into my CSS and tried to make sure there are no borders on tables. I've put the following code into my CSS stylesheet:
table {
border-collapse: separate;
border-spacing: 0;
border: none !important;
border-top: none;
border-bottom: none;
}
caption,
th {
border-bottom: none;
border: none;
border-top: none;
}
td {
font-weight: normal;
text-align: left;
border-top: none;
border: none;
border-bottom: none;
}
tr {
border: none;
border-bottom: none;
border-top: none;
}
Still no luck. Does anyone have a suggestion?
You have a CSS setting:
.entry-content td, .comment-content td {
border-top: 1px solid #EDEDED;
}
Thats the border you see.
This CSS
border-top: none;
border: none;
border-bottom: none;
can be shortened to just
border: none;
Add the following to your CSS:
hr {
height: 0px !important;
}
It seems you're using a CMS software to develop your site and the template you're using is actually putting an <hr> at
<div id="page" ...>
<header id="masthead" ...>
<hgroup ...>
<nav id="site-navigation" ...>
<hr>
</header>
<div id="main" ...>
<footer ...>
</div>

Customize the WebHttp Help Output in WCF

For a service with webHttpBinding and helpEnabled="true", the help information is getting generated properly. Was wondering if it is possible to control the output somehow. Below are the changes I would like to make.
Remove the JSON help as the service doesn't support JSON output. Having it there might be confusing to users. At least, have a way to output a note saying JSON is not supported.
For the example replies shown, use a better example than "String content" where actual value samples can be specified. Would be good if I can supply the object that is used for being serialized as example.
The help page for WCF WebHttp endpoints cannot be customized. You can, however, replace it with your own custom page. It's easy to be implemented, but it's a lot of code to write. The example below shows how this can be done for a simple service.
public class StackOverflow_7005187
{
[DataContract]
public class MyDC
{
[DataMember]
public string str = "The string";
}
[ServiceContract]
public interface ITest
{
[WebInvoke]
string EchoString(string text);
[WebGet]
int Add(int x, int y);
[WebInvoke]
MyDC EchoDC(MyDC input);
[WebGet(UriTemplate = "/help")]
Message GetMainHelpPage();
[WebGet(UriTemplate = "/help/operations/EchoDC")]
Message GetOperationsEchoDCHelpPage();
// help for other operations not implemented
}
public class Service : ITest
{
public string EchoString(string text)
{
return text;
}
public int Add(int x, int y)
{
return x + y;
}
public MyDC EchoDC(MyDC input)
{
return input;
}
public Message GetMainHelpPage()
{
string page = #"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html xmlns=""http://www.w3.org/1999/xhtml"">
<head>
<title>Operations at http://localhost:8000/Service</title>
<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
</head>
<body>
<div id=""content"">
<p class=""heading1"">Operations at http://localhost:8000/Service</p>
<p>This page describes the service operations at this endpoint.</p>
<table>
<tr>
<th>Uri</th>
<th>Method</th>
<th>Description</th>
</tr>
<tr>
<td>Add</td>
<td title=""http://localhost:8000/Service/Add?x={X}&y={Y}"">
<a rel=""operation"" href=""help/operations/Add"">GET</a>
</td>
<td>Service at http://localhost:8000/Service/Add?x={X}&y={Y}</td>
</tr>
<tr>
<td>EchoDC</td>
<td title=""http://localhost:8000/Service/EchoDC"">
<a rel=""operation"" href=""help/operations/EchoDC"">POST</a>
</td>
<td>Service at http://localhost:8000/Service/EchoDC</td>
</tr>
<tr>
<td>EchoString</td>
<td title=""http://localhost:8000/Service/EchoString"">
<a rel=""operation"" href=""help/operations/EchoString"">POST</a>
</td>
<td>Service at http://localhost:8000/Service/EchoString</td>
</tr>
</table>
</div>
</body>
</html>";
return WebOperationContext.Current.CreateStreamResponse(
new MemoryStream(Encoding.UTF8.GetBytes(page)),
"text/html");
}
public Message GetOperationsEchoDCHelpPage()
{
string page = #"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html xmlns=""http://www.w3.org/1999/xhtml"">
<head>
<title>Reference for http://localhost:8000/Service/EchoDC</title>
<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
</head>
<body>
<div id=""content"">
<p class=""heading1"">Reference for http://localhost:8000/Service/EchoDC</p>
<p></p>
<p xmlns=""http://www.w3.org/1999/xhtml"">
<b>Url: </b>
<span class=""uri-template"">http://localhost:8000/Service/EchoDC</span>
</p>
<p xmlns=""http://www.w3.org/1999/xhtml"">
<b>HTTP Method: </b>
<span class=""method"">POST</span>
</p>
<table>
<tr>
<th>Message direction</th>
<th>Format</th>
<th>Body</th>
</tr>
<tr>
<td>Request</td>
<td>Xml</td>
<td>
Example</td>
</tr>
<tr>
<td>Request</td>
<td>Json</td>
<td>
Example
</td>
</tr>
<tr>
<td>Response</td>
<td>Xml</td>
<td>
Example</td>
</tr>
</table>
<p>
<a name=""#request-xml"">The following is an example request Xml body:</a>
<pre class=""request-xml""><StackOverflow_7005187.MyDC xmlns=""http://schemas.datacontract.org/2004/07/WcfForums"">
<str>This is a modified string content</str>
</StackOverflow_7005187.MyDC></pre>
</p>
<p>
<a name=""#request-json"">The following is an example request Json body:</a>
<pre class=""request-json"">{
""str"":""Some content in JSON""
}</pre>
</p>
<p>
<a name=""#response-xml"">The following is an example response Xml body:</a>
<pre class=""response-xml""><StackOverflow_7005187.MyDC xmlns=""http://schemas.datacontract.org/2004/07/WcfForums"">
<str>Another modified XML content</str>
</StackOverflow_7005187.MyDC></pre>
</p>
</div>
</body>
</html>";
return WebOperationContext.Current.CreateStreamResponse(
new MemoryStream(Encoding.UTF8.GetBytes(page)),
"text/html");
}
}
public static void Test()
{
string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
host.AddServiceEndpoint(typeof(ITest), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior { HelpEnabled = false });
host.Open();
Console.WriteLine("Host opened");
Console.Write("Press ENTER to close the host");
Console.ReadLine();
host.Close();
}
}