如何在我的 .NET 应用程序中使用 W3C 标记验证器 API? [英] How might I use the W3C Markup Validator API in my .NET application?

查看:32
本文介绍了如何在我的 .NET 应用程序中使用 W3C 标记验证器 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有一个用于 W3C 标记验证器的API.

我之前问过:有吗?用于 W3C 标记验证器 API 的 .NET 库?

Assaf答案:

<块引用>

此 API 基于 SOAP.如果你想在 .net 应用程序中使用它,你可以只需添加网络参考和代码反对.看起来很简单它基本上是一种单一方法的 API...

因此,我尝试在地址 http://validator.w3.org/check 处添加服务引用".

首先显示对话框:

<块引用>

请等待服务信息正在下载...

那么:

<块引用>

尝试时发生错误...寻找服务'http://validator.w3.org/check'

Visual Studio 添加服务引用对话框 http://img17.imageshack.us/img17/719/addservicereference.gif

错误详情:

<块引用>

HTML 文档不包含 Web服务发现信息.元数据包含一个引用无法解决:'http://validator.w3.org/check'.这内容类型 text/html;字符集=utf-8响应消息的不匹配绑定的内容类型(应用程序/soap+xml;字符集=utf-8).如果使用自定义编码器,请确保IsContentTypeSupported 方法实施得当.首先1024 字节的响应是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><头><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/><标题>验证结果 - W3C 标记验证器</title><link rel="icon" href="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%02%00%00%00%90%91h6%00%00%00%19IDAT(%91c%BCd%AB%C2%40%0A%60%22I%F5%A8%86Q%0DCJ%03%00%DE%B5%01S%07%88%8FG%00%00%00%00IEND%AEB%60%82" type="image/png"/><link rev="made" href="mailto:www-validator@w3.org"/><link rev="start" href="./" title="主页"/><style type="text/css" media="all">@import "./style/base.css";@import "./style/results.css";</style><meta name="keywords" content="HTML,超文本标记语言,验证,W3C 标记验证服务"/><meta name="description" content="W3C 的易用性H

<块引用>

如果服务定义在当前的解决方案,尝试构建解决方案并添加服务再次参考.

如何在我的 .NET 应用程序中使用 W3C 标记验证器 API?

解决方案

W3C 服务不是标准的 SOAP 服务!它可以提供 SOAP 格式的响应,但称其为基于单一 REST URL 的服务http://validator.w3.org/check?uri=YourURLToProof&charset=utf-8&output=soap12

I found that there's an API for the W3C Markup Validator.

I had earlier asked: Is there a .NET library for the W3C Markup Validator API?

Assaf's answer:

This API is SOAP based. If you want to use it in a .net application you can just add the web reference and code against it. Seems simple enough as it's basically a one-method API...

So, I tried to "Add Service Reference" at address http://validator.w3.org/check.

First the dialog displays:

Please wait for service information to be downloaded...

Then:

An error ... occurred while attempting to find services at 'http://validator.w3.org/check'

Visual Studio Add Service Reference Dialog http://img17.imageshack.us/img17/719/addservicereference.gif

Error details:

The HTML document does not contain Web service discovery information. Metadata contains a reference that cannot be resolved: 'http://validator.w3.org/check'. The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>

        Validation Results - W3C Markup Validator</title>
    <link rel="icon" href="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%02%00%00%00%90%91h6%00%00%00%19IDAT(%91c%BCd%AB%C2%40%0A%60%22I%F5%A8%86Q%0DCJ%03%00%DE%B5%01S%07%88%8FG%00%00%00%00IEND%AEB%60%82" type="image/png" />
<link rev="made" href="mailto:www-validator@w3.org" />
<link rev="start" href="./" title="Home Page" />
<style type="text/css" media="all">@import "./style/base.css";
        @import "./style/results.css";</style>
<meta name="keywords" content="HTML, HyperText Markup Language, Validation,
  W3C Markup Validation Service" />
<meta name="description" content="W3C's easy-to-use
  H

If the service is defined in the current solution, try building the solution and adding the service reference again.

How can I use the W3C Markup Validator API in my .NET application?

解决方案

The W3C Service is no standard SOAP Service! It can give a SOAP formatted response but to call it's a sinple REST URL based Service http://validator.w3.org/check?uri=YourURLToProof&charset=utf-8&output=soap12

这篇关于如何在我的 .NET 应用程序中使用 W3C 标记验证器 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆