<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>THE .NET WAY &#187; SOAP &#8211;  &#8211; The .Net Way</title>
	<atom:link href="http://www.thedotnetway.net/tag/soap/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedotnetway.net</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 14:05:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cambiar el &#8220;element name&#8221; del tipo devuelto en los servicios web</title>
		<link>http://www.thedotnetway.net/2011/11/10/cambiar-el-element-name-del-tipo-devuelto-en-los-servicios-web/</link>
		<comments>http://www.thedotnetway.net/2011/11/10/cambiar-el-element-name-del-tipo-devuelto-en-los-servicios-web/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 12:18:10 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Trucos]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2011/11/10/cambiar-el-element-name-del-tipo-devuelto-en-los-servicios-web/</guid>
		<description><![CDATA[Los servicios web de ASP.NET tienen eso, que cuando quieres devolver tu objeto Person te lo renombran al nombre del método + result y te lo meten dentro de un método + response, así este código: public class Person { public string Name { get; set; } } &#160; [WebService(Namespace = &#34;http://tempuri.org/&#34;)] public class Service<a class="rmore" href="http://www.thedotnetway.net/2011/11/10/cambiar-el-element-name-del-tipo-devuelto-en-los-servicios-web/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Los servicios web de ASP.NET tienen eso, que cuando quieres devolver tu objeto Person te lo renombran al nombre del método + result y te lo meten dentro de un método + response, así este código:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Person</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Name { get; set; }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[WebService(Namespace = <span style="color: #006080">&quot;http://tempuri.org/&quot;</span>)]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Service : System.Web.Services.WebService</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> Service () {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    [WebMethod]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> Person Get() {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Person { Name = <span style="color: #006080">&quot;Pepito&quot;</span> };</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<p><!--CRLF--></div>
</div>
<p>Te generara esto:<a href="http://www.thedotnetway.net/wp-content/uploads/2011/11/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.thedotnetway.net/wp-content/uploads/2011/11/image_thumb.png" width="569" height="364" /></a></p>
<p>Sin embargo usando atributos de Serializacion en la clase Person, definiéndole el nombre y el tipo, y de Soap en la clase Service conseguiremos que nos devuelva el objeto como lo hemos definido.</p>
<p>Así que este código:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[System.Xml.Serialization.XmlRootAttribute(ElementName = <span style="color: #006080">&quot;Person&quot;</span>, DataType = <span style="color: #006080">&quot;Person&quot;</span>)]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Person</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Name { get; set; }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">[SoapDocumentService(Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Bare), WebService(Namespace = <span style="color: #006080">&quot;http://tempuri.org/&quot;</span>)]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Service : System.Web.Services.WebService</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">{</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> Service () {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    [WebMethod]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> Person Get() {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Person { Name = <span style="color: #006080">&quot;Pepito&quot;</span> };</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">}</pre>
<p><!--CRLF--></div>
</div>
<p>Te genera esto:</p>
<p><a href="http://www.thedotnetway.net/wp-content/uploads/2011/11/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.thedotnetway.net/wp-content/uploads/2011/11/image_thumb1.png" width="668" height="364" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2011/11/10/cambiar-el-element-name-del-tipo-devuelto-en-los-servicios-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cabeceras en mensajes SOAP</title>
		<link>http://www.thedotnetway.net/2009/11/27/cabeceras-en-mensajes-soap/</link>
		<comments>http://www.thedotnetway.net/2009/11/27/cabeceras-en-mensajes-soap/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 12:38:14 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WebServices]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2009/11/27/cabeceras-en-mensajes-soap/</guid>
		<description><![CDATA[Añadir cabeceras personalizadas a los mensajes de nuestros servicios web es realmente sencillo, en esas cabeceras podemos transportar cualquier dato que nos interese tokens, usuario y contraseña, lo que sea.. Hay que hacer lo siguiente: 1- Crear la clase con los datos que herede de SoapHeader public class SoapHeaderData: SoapHeader { public string Data1; public<a class="rmore" href="http://www.thedotnetway.net/2009/11/27/cabeceras-en-mensajes-soap/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Añadir cabeceras personalizadas a los mensajes de nuestros servicios web es realmente sencillo, en esas cabeceras podemos transportar cualquier dato que nos interese tokens, usuario y contraseña, lo que sea..</p>
<p>Hay que hacer lo siguiente:</p>
<p>1- Crear la clase con los datos que herede de SoapHeader</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">SoapHeaderData</span>: <span style="color: #2b91af">SoapHeader
</span>{
    <span style="color: blue">public string </span>Data1;
    <span style="color: blue">public string </span>Data2;
    <span style="color: blue">public string </span>Data3;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a>2- Crear una propiedad en el servicio web con esa clase y la etiqueta SoapHeader con el nombre de la propiedad al método web, en esa propiedad tendremos los datos</p>
<pre class="code">[<span style="color: #2b91af">WebServiceBinding</span>(ConformsTo = <span style="color: #2b91af">WsiProfiles</span>.BasicProfile1_1)]
<span style="color: blue">public class </span><span style="color: #2b91af">Service </span>: System.Web.Services.<span style="color: #2b91af">WebService
</span>{
    <span style="color: blue">public </span><span style="color: #2b91af">SoapHeaderData </span>HeaderData;

    [<span style="color: #2b91af">WebMethod</span>]
    [<span style="color: #2b91af">SoapHeader</span>(<span style="color: #a31515">&quot;HeaderData&quot;</span>)]
    <span style="color: blue">public string </span>HelloWorld() {
        <span style="color: blue">return </span><span style="color: #a31515">&quot;Hello World &quot; </span>+ HeaderData.Data1 + <span style="color: #a31515">&quot;, &quot; </span>+
                                HeaderData.Data2 + <span style="color: #a31515">&quot;, &quot; </span>+
                                HeaderData.Data3;
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a>Solo haciendo esto ya tenemos la cabecera en nuestra petición SOAP: </p>
<p><a href="http://www.thedotnetway.net/wp-content/uploads/2009/11/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.thedotnetway.net/wp-content/uploads/2009/11/image_thumb.png" width="474" height="238" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2009/11/27/cabeceras-en-mensajes-soap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Soap Extension</title>
		<link>http://www.thedotnetway.net/2009/10/07/soap-extension/</link>
		<comments>http://www.thedotnetway.net/2009/10/07/soap-extension/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 14:41:30 +0000</pubDate>
		<dc:creator>jordicb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asmx]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[SOAP Extension]]></category>

		<guid isPermaLink="false">http://www.thedotnetway.net/2009/10/07/soap-extension/</guid>
		<description><![CDATA[Soap Extension es un mecanismo de ASP.NET para interceptar mensages Soap cuando entran o salen de nuestro sistema. Existen cuatro puntos en todo el proceso del mensaje en los cuales podremos interceptar el mensaje: Para implementarla solo tenemos que crear una clase que herede de System.Web.Services.Protocols.SoapExtension. Aquí tienes un ejemplo sacado de la documentación de<a class="rmore" href="http://www.thedotnetway.net/2009/10/07/soap-extension/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Soap Extension es un mecanismo de ASP.NET para interceptar mensages Soap cuando entran o salen de nuestro sistema. Existen cuatro puntos en todo el proceso del mensaje en los cuales podremos interceptar el mensaje:</p>
<p><a href="http://www.thedotnetway.net/wp-content/uploads/2009/10/esw638yk_xmlwebservicelifetimeenusVS_71.gif"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="esw638yk_xmlwebservicelifetime(en-us,VS_71)" border="0" alt="esw638yk_xmlwebservicelifetime(en-us,VS_71)" src="http://www.thedotnetway.net/wp-content/uploads/2009/10/esw638yk_xmlwebservicelifetimeenusVS_71_thumb.gif" width="475" height="245" /></a> </p>
<p>Para implementarla solo tenemos que crear una clase que herede de System.Web.Services.Protocols.SoapExtension. Aquí tienes un ejemplo sacado de la documentación de MSDN, intercepta los mensajes en la entrada duespues de serializar (Paso 2 en el gráfico) y en la salida antes de Deserializar (Paso 4 en el gráfico) y guarda los mensajes en disco.</p>
</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">TraceExtension </span>: <span style="color: #2b91af">SoapExtension
</span>{</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<pre class="code">    Stream oldStream;
    Stream newStream;
    <span style="color: blue">string </span>filename;

    <span style="color: green">// Save the Stream representing the SOAP request or SOAP response into
    // a local memory buffer.
    </span><span style="color: blue">public override </span>Stream ChainStream( Stream stream ){
        oldStream = stream;
        newStream = <span style="color: blue">new </span>MemoryStream();
        <span style="color: blue">return </span>newStream;
    }

    <span style="color: green">// When the SOAP extension is accessed for the first time, the XML Web
    // service method it is applied to is accessed to store the file
    // name passed in, using the corresponding SoapExtensionAttribute.
    </span><span style="color: blue">public override object </span>GetInitializer(LogicalMethodInfo methodInfo,
	                                   SoapExtensionAttribute attribute)
    {
        <span style="color: blue">return </span>((TraceExtensionAttribute) attribute).Filename;
    }

    <span style="color: green">// The SOAP extension was configured to run using a configuration file
    // instead of an attribute applied to a specific XML Web service
    // method.
    </span><span style="color: blue">public override object </span>GetInitializer(Type WebServiceType)
    {
      <span style="color: green">// Return a file name to log the trace information to, based on the
      // type.
      </span><span style="color: blue">return </span><span style="color: #a31515">&quot;C:\\&quot; </span>+ WebServiceType.FullName + <span style="color: #a31515">&quot;.log&quot;</span>;
    }

    <span style="color: green">// Receive the file name stored by GetInitializer and store it in a
    // member variable for this specific instance.
    </span><span style="color: blue">public override void </span>Initialize(<span style="color: blue">object </span>initializer)
    {
        filename = (<span style="color: blue">string</span>) initializer;
    }

    <span style="color: green">//  If the SoapMessageStage is such that the SoapRequest or
    //  SoapResponse is still in the SOAP format to be sent or received,
    //  save it out to a file.
    </span><span style="color: blue">public override void </span>ProcessMessage(SoapMessage message)
    {
        <span style="color: blue">switch </span>(message.Stage) {
        <span style="color: blue">case </span>SoapMessageStage.BeforeSerialize:
            <span style="color: blue">break</span>;
        <span style="color: blue">case </span>SoapMessageStage.AfterSerialize:
            WriteOutput(message);
            <span style="color: blue">break</span>;
        <span style="color: blue">case </span>SoapMessageStage.BeforeDeserialize:
            WriteInput(message);
            <span style="color: blue">break</span>;
        <span style="color: blue">case </span>SoapMessageStage.AfterDeserialize:
            <span style="color: blue">break</span>;
        <span style="color: blue">default</span>:
             <span style="color: blue">throw new </span>Exception(<span style="color: #a31515">&quot;invalid stage&quot;</span>);
        }
    }

    <span style="color: blue">public void </span>WriteOutput(SoapMessage message){
        newStream.Position = 0;
        FileStream fs = <span style="color: blue">new </span>FileStream(filename, FileMode.Append,
                                       FileAccess.Write);
        StreamWriter w = <span style="color: blue">new </span>StreamWriter(fs);

        <span style="color: blue">string </span>soapString =
          (message <span style="color: blue">is </span>SoapServerMessage) ? <span style="color: #a31515">&quot;SoapResponse&quot; </span>: <span style="color: #a31515">&quot;SoapRequest&quot;</span>;
        w.WriteLine(<span style="color: #a31515">&quot;-----&quot; </span>+ soapString + <span style="color: #a31515">&quot; at &quot; </span>+ DateTime.Now);
        w.Flush();
        Copy(newStream, fs);
        w.Close();
        newStream.Position = 0;
        Copy(newStream, oldStream);
    }

    <span style="color: blue">public void </span>WriteInput(SoapMessage message){
        Copy(oldStream, newStream);
        FileStream fs = <span style="color: blue">new </span>FileStream(filename, FileMode.Append,
                                       FileAccess.Write);
        StreamWriter w = <span style="color: blue">new </span>StreamWriter(fs);

        <span style="color: blue">string </span>soapString = (message <span style="color: blue">is </span>SoapServerMessage) ?
                            <span style="color: #a31515">&quot;SoapRequest&quot; </span>: <span style="color: #a31515">&quot;SoapResponse&quot;</span>;
        w.WriteLine(<span style="color: #a31515">&quot;-----&quot; </span>+ soapString +
                    <span style="color: #a31515">&quot; at &quot; </span>+ DateTime.Now);
        w.Flush();
        newStream.Position = 0;
        Copy(newStream, fs);
        w.Close();
        newStream.Position = 0;
    }

    <span style="color: blue">void </span>Copy(Stream from, Stream to)
    {
        TextReader reader = <span style="color: blue">new </span>StreamReader(from);
        TextWriter writer = <span style="color: blue">new </span>StreamWriter(to);
        writer.WriteLine(reader.ReadToEnd());
        writer.Flush();
    }
  }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Para poder insertar la SoapExtension en la entrada y salida de un WebMethod hay que crear una clase que herede de SoapExtensionAttribute cuya propiedad ExtensionType le dice al framework que clase SoapExtension utilizar. También tiene una propiedad Priority para que en caso de que haya más de un SoapExtension el sistema sepa en que orden ejecutarlas:</p>
<pre class="code"><span style="color: green">  // Create a SoapExtensionAttribute for the SOAP Extension that can be
  // applied to an XML Web service method.
 </span>[AttributeUsage(AttributeTargets.Method)]
 <span style="color: blue">public class </span>TraceExtensionAttribute : SoapExtensionAttribute {

   <span style="color: blue">private string </span>filename = <span style="color: #a31515">&quot;c:\\log.txt&quot;</span>;
   <span style="color: blue">private int </span>priority;

   <span style="color: blue">public override </span>Type ExtensionType {
       <span style="color: blue">get </span>{ <span style="color: blue">return typeof</span>(TraceExtension); }
   }

   <span style="color: blue">public override int </span>Priority {
       <span style="color: blue">get </span>{ <span style="color: blue">return </span>priority; }
       <span style="color: blue">set </span>{ priority = value; }
   }

   <span style="color: blue">public string </span>Filename {
       <span style="color: blue">get </span>{
           <span style="color: blue">return </span>filename;
       }
       <span style="color: blue">set </span>{
           filename = value;
       }
   }</pre>
<p>Para que un WebMethod utilice la SoapExtension solo queda aplicar el SoapExtensionAttribute al método:</p>
<p>&#160;</p>
<pre class="code">[WebMethod]
[TraceExtension()]
<span style="color: blue">public string </span>MetodoWeb(<span style="color: blue">string </span>str)
{
    <span style="color: blue">return </span><span style="color: #a31515">&quot;Hola&quot;</span>;
}</pre>
<p>&#160;</p>
<p><a href="http://11011.net/software/vspaste">&#160;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2009/10/07/soap-extension/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Obtener los datos XML de un Documento SOAP</title>
		<link>http://www.thedotnetway.net/2009/01/09/obtener-los-datos-xml-de-un-documento-soap/</link>
		<comments>http://www.thedotnetway.net/2009/01/09/obtener-los-datos-xml-de-un-documento-soap/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 08:23:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2009/01/09/obtener-los-datos-xml-de-un-documento-soap/</guid>
		<description><![CDATA[Mas de mi servicio &#34;impersonal&#34; &#8230; Resulta que ahora también recibe documentos SOAP, así que tengo que extraer los datos del mensaje SOAP con este código: private XmlDocument GetSOAPBody(XmlDocument xmlSoap) { const string SOAP_NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope/"; XmlNodeList nodes = xmlSoap.GetElementsByTagName("Body", SOAP_NAMESPACE); if (nodes.Count == 0) return xmlSoap; XmlElement body = (XmlElement)nodes.Item(0); nodes = body.ChildNodes; for<a class="rmore" href="http://www.thedotnetway.net/2009/01/09/obtener-los-datos-xml-de-un-documento-soap/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Mas de mi servicio &quot;impersonal&quot; &#8230;</p>
<p>Resulta que ahora también recibe documentos SOAP, así que tengo que extraer los datos del mensaje SOAP con este código:</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:36df10a3-f25c-49cb-9410-dbd5e2b45669" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;font-family:Microsoft Sans Serif;font-size:11px;"><span style="color:#0000FF;">private</span><span style="color:#000000;"> XmlDocument GetSOAPBody(XmlDocument xmlSoap)
    {

              </span><span style="color:#0000FF;">const</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> SOAP_NAMESPACE </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">http://schemas.xmlsoap.org/soap/envelope/</span><span style="color:#800000;">"</span><span style="color:#000000;">;
              XmlNodeList nodes </span><span style="color:#000000;">=</span><span style="color:#000000;"> xmlSoap.GetElementsByTagName(</span><span style="color:#800000;">"</span><span style="color:#800000;">Body</span><span style="color:#800000;">"</span><span style="color:#000000;">, SOAP_NAMESPACE);

          </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (nodes.Count </span><span style="color:#000000;">==</span><span style="color:#000000;"> </span><span style="color:#800080;">0</span><span style="color:#000000;">) </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> xmlSoap;

          XmlElement body </span><span style="color:#000000;">=</span><span style="color:#000000;"> (XmlElement)nodes.Item(</span><span style="color:#800080;">0</span><span style="color:#000000;">);

          nodes </span><span style="color:#000000;">=</span><span style="color:#000000;"> body.ChildNodes;
          </span><span style="color:#0000FF;">for</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">int</span><span style="color:#000000;"> i </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">0</span><span style="color:#000000;">; i </span><span style="color:#000000;">&lt;</span><span style="color:#000000;"> nodes.Count; i</span><span style="color:#000000;">++</span><span style="color:#000000;">)
          {
              XmlNode node </span><span style="color:#000000;">=</span><span style="color:#000000;"> nodes.Item(i);
              </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (node </span><span style="color:#0000FF;">is</span><span style="color:#000000;"> XmlElement)
              {
                  xmlSoap </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> XmlDocument();
                  xmlSoap.LoadXml(node.OuterXml);
                  IsSOAP </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">true</span><span style="color:#000000;">;
                  </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> xmlSoap;
              }
          }

          </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> xmlSoap;
      }  </span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Funciona bastante bien, ahora estoy con el de generar las respuestas de OK y de Error, ya lo publicare <img src='http://www.thedotnetway.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2009/01/09/obtener-los-datos-xml-de-un-documento-soap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pasar Credenciales en Http Header Authorization</title>
		<link>http://www.thedotnetway.net/2008/11/27/pasar-credenciales-en-http-header-authorization/</link>
		<comments>http://www.thedotnetway.net/2008/11/27/pasar-credenciales-en-http-header-authorization/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 08:29:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WebServices]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2008/11/27/pasar-credenciales-en-http-header-authorization/</guid>
		<description><![CDATA[Me he estado volviendo medio loco estos días intentando conectar con el servicio de un tercero, la documentación no era todo lo clara que uno espera&#8230; Intente pasarle las Credenciales como NetworkCredentials en el HttpRequest y nada, añadiendo cabeceras de autentificación al mensaje SOAP y nada, al final las espera en una cabecera Http. ¿Como<a class="rmore" href="http://www.thedotnetway.net/2008/11/27/pasar-credenciales-en-http-header-authorization/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Me he estado volviendo medio loco estos días intentando conectar con el servicio de un tercero, la documentación no era todo lo clara que uno espera&#8230;</p>
<p>Intente pasarle las Credenciales como NetworkCredentials en el HttpRequest y nada, añadiendo cabeceras de autentificación al mensaje SOAP y nada, al final las espera en una cabecera Http.</p>
<p>¿Como se pasan allí? pues así:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e8070795-6a41-42ea-8b82-b2d0247b209e" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;font-family:Microsoft Sans Serif;font-size:11px;"><span style="color:#000000;">HttpWebRequest req </span><span style="color:#000000;">=</span><span style="color:#000000;"> (HttpWebRequest)WebRequest.Create(</span><span style="color:#800000;">"</span><span style="color:#800000;">la url del servicio</span><span style="color:#800000;">"</span><span style="color:#000000;">);

req.Headers.Add(</span><span style="color:#800000;">"</span><span style="color:#800000;">SOAPAction</span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#800000;">"</span><span style="color:#800000;">la accion</span><span style="color:#800000;">"</span><span style="color:#000000;">);
req.ContentType </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">application/soap+xml</span><span style="color:#800000;">"</span><span style="color:#000000;">;
req.Accept </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">text/xml</span><span style="color:#800000;">"</span><span style="color:#000000;">;
req.Method </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">POST</span><span style="color:#800000;">"</span><span style="color:#000000;">;
</span><span style="color:#0000FF;">byte</span><span style="color:#000000;">[] authBytes </span><span style="color:#000000;">=</span><span style="color:#000000;"> Encoding.UTF8.GetBytes((</span><span style="color:#800000;">"</span><span style="color:#800000;">Usuario:Pass</span><span style="color:#800000;">"</span><span style="color:#000000;">).ToCharArray());
req.Headers.Add(</span><span style="color:#800000;">"</span><span style="color:#800000;">Authorization</span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#800000;">"</span><span style="color:#800000;">Basic </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">+</span><span style="color:#000000;"> Convert.ToBase64String(authBytes));       </span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p><span style="font-size:10pt;"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2008/11/27/pasar-credenciales-en-http-header-authorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cliente SOAP para servicios PHP o Java AXIS</title>
		<link>http://www.thedotnetway.net/2008/04/14/cliente-soap-para-servicios-php-o-java-axis/</link>
		<comments>http://www.thedotnetway.net/2008/04/14/cliente-soap-para-servicios-php-o-java-axis/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 14:08:00 +0000</pubDate>
		<dc:creator>Emilio Torrens</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://thedotnetway.wordpress.com/2008/04/14/cliente-soap-para-servicios-php-o-java-axis/</guid>
		<description><![CDATA[Aquí dejo una clase para consumir servicios web vía SOAP en los que no tengamos el WSDL o que el Wizard nos de problemas: using System; using System.Text; using System.IO; using System.Net; using System.Xml; namespace Test { class SOAPClient { public static XmlDocument SendMsg(XmlDocument xmlRQ) { byte[] byte1; Stream myStream; StreamReader readStream; HttpWebRequest wr =<a class="rmore" href="http://www.thedotnetway.net/2008/04/14/cliente-soap-para-servicios-php-o-java-axis/">&#160;&#160; Read More ...</a>]]></description>
			<content:encoded><![CDATA[<p>Aquí dejo una clase para consumir servicios web vía SOAP en los que no tengamos el WSDL o que el Wizard nos de problemas: </p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1642f31f-25a9-48f8-9a65-f0d8294f2ab1" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;font-family:Microsoft Sans Serif;font-size:11px;"><span style="color:#0000FF;">using</span><span style="color:#000000;"> System;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Text;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.IO;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Net;
</span><span style="color:#0000FF;">using</span><span style="color:#000000;"> System.Xml;

</span><span style="color:#0000FF;">namespace</span><span style="color:#000000;"> Test
    {
    </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> SOAPClient
        {

        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">static</span><span style="color:#000000;"> XmlDocument SendMsg(XmlDocument xmlRQ)
            {
                </span><span style="color:#0000FF;">byte</span><span style="color:#000000;">[] byte1;
                Stream myStream;
                StreamReader readStream;

                HttpWebRequest wr </span><span style="color:#000000;">=</span><span style="color:#000000;">
                    (HttpWebRequest)WebRequest.
                    Create(</span><span style="color:#800000;">"</span><span style="color:#800000;">http://laurl.com/ws.php</span><span style="color:#800000;">"</span><span style="color:#000000;">);

                byte1 </span><span style="color:#000000;">=</span><span style="color:#000000;">
                Encoding.GetEncoding(</span><span style="color:#800080;">1252</span><span style="color:#000000;">).GetBytes(xmlRQ.OuterXml);
                wr.Method </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">POST</span><span style="color:#800000;">"</span><span style="color:#000000;">;
                wr.Headers.Add(</span><span style="color:#800000;">"</span><span style="color:#800000;">SOAPAction</span><span style="color:#800000;">"</span><span style="color:#000000;">, </span><span style="color:#800000;">""</span><span style="color:#000000;">);
                wr.ContentType </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">text/xml; charset=\"utf-8\"</span><span style="color:#800000;">"</span><span style="color:#000000;">;
                wr.Accept </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">text/xml</span><span style="color:#800000;">"</span><span style="color:#000000;">;

                myStream </span><span style="color:#000000;">=</span><span style="color:#000000;"> wr.GetRequestStream();
                myStream.Write(byte1, </span><span style="color:#800080;">0</span><span style="color:#000000;">, byte1.Length);
                myStream.Close();

                myStream </span><span style="color:#000000;">=</span><span style="color:#000000;"> wr.GetResponse().GetResponseStream();
                readStream </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> StreamReader(myStream);
                XmlDocument xmlDoc </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> XmlDocument();
                xmlDoc.Load(readStream);
                myStream.Close();

                </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> getSOAPPayload(xmlDoc, </span><span style="color:#800000;">"</span><span style="color:#800000;">body</span><span style="color:#800000;">"</span><span style="color:#000000;">);
            }

          </span><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">static</span><span style="color:#000000;"> XmlDocument getSOAPPayload(XmlDocument rs,
                                                    </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> Tag)
            {

                XmlNode xmlNode </span><span style="color:#000000;">=</span><span style="color:#000000;">
                    rs.GetElementsByTagName(Tag)[</span><span style="color:#800080;">0</span><span style="color:#000000;">].FirstChild;
                XmlDocument xmlResult </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> XmlDocument();
                xmlResult.LoadXml(xmlNode.Value);
                </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> xmlResult;
            }

        }
    }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
]]></content:encoded>
			<wfw:commentRss>http://www.thedotnetway.net/2008/04/14/cliente-soap-para-servicios-php-o-java-axis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

