<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>{ Duane.Wingett } - Web Services</title>
    <link>http://www.duanewingett.info/</link>
    <description>.Net Code Monkey</description>
    <language>en-gb</language>
    <copyright>Duane Wingett</copyright>
    <lastBuildDate>Thu, 03 Apr 2008 12:24:24 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mail@duanewingett.info</managingEditor>
    <webMaster>mail@duanewingett.info</webMaster>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=4d4be93f-a7dd-4988-a966-23872fc4651b</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,4d4be93f-a7dd-4988-a966-23872fc4651b.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,4d4be93f-a7dd-4988-a966-23872fc4651b.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=4d4be93f-a7dd-4988-a966-23872fc4651b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of my on-going projects uses a light weight client to call a web service, which
runs a fairly long running process, part of which will take at minimum five minutes.
Testing has proved that the request to the webserver will cause a timeout. I belive
the default is about 90 seconds. There are probably many ways to circumvent this problem,
but the two that i am concidering are:
</p>
        <ul>
          <li>
Increase the time out settings to cover the longest anticipated duration. 
</li>
          <li>
To implement fire and forget by the client, and let the webservice spawn an additional
thread to carry out the long process, returning the request almost imeadiatley.</li>
        </ul>
        <h3>Increasing Timeout settings
</h3>
        <h4>Solution
</h4>
        <p>
From a little web reasearch it appears that there are three settings that may be able
to assist me.
</p>
        <ul>
          <li>
The timeout property on the webservice proxy 
</li>
          <li>
The http-runtime setting in App.Config of the calling assembly 
</li>
          <li>
The http-runtime setting in Web.Config of the webservice.</li>
        </ul>
        <h4>Pros
</h4>
        <ul>
          <li>
Allows trapping of exceptions during the process and passing them back to
the client in the form of a <font color="#7fffd4">SoapException</font>.</li>
        </ul>
        <h4>Cons
</h4>
        <ul>
          <li>
Process time may vary over operational lifetime of project requiring changing of configuration
files, and possibly recompliling everytime the threshold is exceeded. 
</li>
          <li>
If the request times out there is no way of knowing if the process is still running.</li>
        </ul>
        <h3>Fire and Forget
</h3>
        <h4>Solution
</h4>
        <p>
My second solution would be to use the BackgroundWorker to spawn a new thread
in the code called the from the WebService's WebMethod.
</p>
        <h4>Pros
</h4>
        <ul>
          <li>
Allows imediate return of the WebMethod request so very little risk of time out, and
therefore virtually limit less total process time. 
</li>
          <li>
Because the client needs to request whether the process has finished any way, if an
exception occurs this can be handled and the status relayed back to the client at
the next request.</li>
        </ul>
        <h4>Cons
</h4>
        <ul>
          <li>
Requires state of progress or completion to be stored by webservice (in database,
text file, or similar). 
</li>
          <li>
Requires the calling client to keep "asking" the webservice if the task
has finished. This will involve more coding and the client having to "know" that it
has to keep asking for the progress and or status of completion of the task. 
</li>
          <li>
Requires extra coding to provide client with information if an exception occurs during
the process.</li>
        </ul>
        <p>
So which is the best method to choose? Well this is probably going to sound like a
bit of a cop-out, but it really does depend upon the application and how it is to
be used. Each solution has it merits and its drawbacks as you can see.
</p>
        <p>
For the project that I am concerned with I will no doubt use the fire and forget solution
so I am not limited to time outs, as one of the processes (Archiving) will gradually
take longer and longer to complete over the working life of the application, and I
do not wish to be having to change the timeout and recompile frequently. I am also
concerned that the timeout required couls easily surpass acceptable limits.
</p>
        <p>
So how would <em>you</em> choose to carry out this task? Do you have any other solutions?
Can you see any more advanatages or disadvantages of using either of the two solutions
presented? your thoughts are welcom as always.
</p>
        <p>
          <font size="1">To be continued...</font>
        </p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=4d4be93f-a7dd-4988-a966-23872fc4651b" />
      </body>
      <title>Long running processes within a webservice. Extend request timeout vs fire and forget?</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,4d4be93f-a7dd-4988-a966-23872fc4651b.aspx</guid>
      <link>http://www.duanewingett.info/2008/04/03/LongRunningProcessesWithinAWebserviceExtendRequestTimeoutVsFireAndForget.aspx</link>
      <pubDate>Thu, 03 Apr 2008 12:24:24 GMT</pubDate>
      <description>&lt;p&gt;
One of my on-going projects uses a light weight client to call a web service, which
runs a fairly long running process, part of which will take at minimum five minutes.
Testing has proved that the request to the webserver will cause a timeout. I belive
the default is about 90 seconds. There are probably many ways to circumvent this problem,
but the two that i am concidering are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Increase the time out settings to cover the longest anticipated duration. 
&lt;li&gt;
To implement fire and forget by the client, and let the webservice spawn an additional
thread to carry out the long process, returning the request almost imeadiatley.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Increasing Timeout settings
&lt;/h3&gt;
&lt;h4&gt;Solution
&lt;/h4&gt;
&lt;p&gt;
From a little web reasearch it appears that there are three settings that may be able
to assist me.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The timeout property on the webservice proxy 
&lt;li&gt;
The http-runtime setting in App.Config of the calling assembly 
&lt;li&gt;
The http-runtime setting in Web.Config of the webservice.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Pros
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Allows trapping of exceptions&amp;nbsp;during the process&amp;nbsp;and passing them back to
the client in the form of a &lt;font color=#7fffd4&gt;SoapException&lt;/font&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Cons
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Process time may vary over operational lifetime of project requiring changing of configuration
files, and possibly recompliling everytime the threshold is exceeded. 
&lt;li&gt;
If the request times out there is no way of knowing if the process is still running.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Fire and Forget
&lt;/h3&gt;
&lt;h4&gt;Solution
&lt;/h4&gt;
&lt;p&gt;
My second solution would be to&amp;nbsp;use the BackgroundWorker to spawn a new thread
in the code called the from the WebService's WebMethod.
&lt;/p&gt;
&lt;h4&gt;Pros
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Allows imediate return of the WebMethod request so very little risk of time out, and
therefore virtually limit less total process time. 
&lt;li&gt;
Because the client needs to request whether the process has finished any way, if an
exception occurs this can be handled and the status relayed back to the client at
the next request.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Cons
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
Requires state of progress or completion to be stored by webservice (in database,
text file, or similar). 
&lt;li&gt;
Requires&amp;nbsp;the calling client to keep "asking" the webservice if the&amp;nbsp;task
has finished. This will involve more coding and the client having to "know" that it
has to keep asking for the progress and or status of completion of the task. 
&lt;li&gt;
Requires extra coding to provide client with information if an exception occurs during
the process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
So which is the best method to choose? Well this is probably going to sound like a
bit of a cop-out, but it really does depend upon the application and how it is to
be used. Each solution has it merits and its drawbacks as you can see.
&lt;/p&gt;
&lt;p&gt;
For the project that I am concerned with I will no doubt use the fire and forget solution
so I am not limited to time outs, as one of the processes (Archiving) will gradually
take longer and longer to complete over the working life of the application, and I
do not wish to be having to change the timeout and recompile frequently. I am also
concerned that the timeout required couls easily surpass acceptable limits.
&lt;/p&gt;
&lt;p&gt;
So how would &lt;em&gt;you&lt;/em&gt; choose to carry out this task? Do you have any other solutions?
Can you see any more advanatages or disadvantages of using either of the two solutions
presented? your thoughts are welcom as always.
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;To be continued...&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=4d4be93f-a7dd-4988-a966-23872fc4651b" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,4d4be93f-a7dd-4988-a966-23872fc4651b.aspx</comments>
      <category>.Net</category>
      <category>C#</category>
      <category>Long Running Processes</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=eeefddc3-6c61-4adb-aad3-d43f78c94121</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,eeefddc3-6c61-4adb-aad3-d43f78c94121.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,eeefddc3-6c61-4adb-aad3-d43f78c94121.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=eeefddc3-6c61-4adb-aad3-d43f78c94121</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h2>Background
</h2>
        <p>
As part of an ongoing project where a light weight client application needs to communicate
with a database via a webservice I have been trying to get my head around a the best
way to encapsulate data within custom objects and pass it from the client 's GUI to
the Web Service's Data Access layer without replicating too much code or having the
the client hold a reference to the same assembly as the webservice.
</p>
        <p>
The intention is for the client application to have 3 layers, the presentation layer,
a Business Entity / Business Logic layer and an Webservice Adapter layer. The Webservice
will have the WebService layer, it's own Business Entity / Business Logic layer and
a Data Access layer. 
</p>
        <h2>Initial Thoughts
</h2>
        <p>
My initial thoughts were to create an assembly which would hold a set of interfaces
that will describe the business entities that both parts of the application would
use. For example the interface fot the job object would be:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">interface</span> IJob
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> Id; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> CreatedBy; <font color="#7fffd4">DateTime</font> CreatedOn;
. . <font color="#7fffd4">DateTime</font> LastAccessed; }</span>
        </pre>
        <p>
This would require that both pairs of business entity assemblies would need to have
a reference to the assembly. My plan was then to return from the webservice's webmethods
the interface rather than the object. For example.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[WebMethod] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span> IJob
GetJobById(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> id)
{ . . }</span>
        </pre>
        <p>
          <font size="1">
            <font size="2">My plan was then bind the form controls to the properties
of the interface but among a couple of minor flaws in my plan, there was <strong>one
big</strong> one... It appears that you <em>can not</em> return an interface from
a web service. I assume do to it not being serialisable. A little research later
it appears that a better way would be to would be to use a shared base class for the
business entities on both sides of the void, so to speak. So back to the drawing board
slightly..</font>
          </font>
        </p>
        <h2>Second Thoughts
</h2>
        <p>
So now I'm thinking I need to create an abstract base class for the objects
in the business entitiy assemblies in both the client and the webservice to inherit
from. If I ensure the base classes implement the interfaces, then I can still bind
my controls to the interfaces properties. So ignoring the various properties of the
class I now have a bas class that implements the previosu
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">protected</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">abstract</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> BaseJob
: IJob { . . }</span>
        </pre>
        <p>
So now the Job class in each business entity layer will inherit from the BaseJob abstract
class which implements the IJob interface.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> Job
: BaseJob { . . }</span>
        </pre>
        <p>
          <font size="1">
            <font size="2">So this means that now rather than just having a reference
to the assembly with the interfaces in for each business entity assembly I now have
a reference to the base class assembly too. Is this really the way I want to go?</font>
          </font>
        </p>
        <p>
          <font size="1">To be continued...</font>
        </p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=eeefddc3-6c61-4adb-aad3-d43f78c94121" />
      </body>
      <title>Same objects on opposite sides of the void...</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,eeefddc3-6c61-4adb-aad3-d43f78c94121.aspx</guid>
      <link>http://www.duanewingett.info/2008/03/31/SameObjectsOnOppositeSidesOfTheVoid.aspx</link>
      <pubDate>Mon, 31 Mar 2008 15:30:16 GMT</pubDate>
      <description>&lt;h2&gt;Background
&lt;/h2&gt;
&lt;p&gt;
As part of an ongoing project where a light weight client application needs to communicate
with a database via a webservice I have been trying to get my head around a the best
way to encapsulate data within custom objects and pass it from the client 's GUI to
the Web Service's Data Access layer without replicating too much code or having the
the client hold a reference to the same assembly as the webservice.
&lt;/p&gt;
&lt;p&gt;
The intention is for the client application to have 3 layers, the presentation layer,
a Business Entity / Business Logic layer and an Webservice Adapter layer. The Webservice
will have the WebService layer, it's own Business Entity / Business Logic layer and
a Data Access layer. 
&lt;/p&gt;
&lt;h2&gt;Initial Thoughts
&lt;/h2&gt;
&lt;p&gt;
My initial thoughts were to create an assembly which would hold a set of interfaces
that will describe the business entities that both parts of the application would
use. For example the interface fot the job object would be:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;interface&lt;/span&gt; IJob
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; Id; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; CreatedBy; &lt;font color=#7fffd4&gt;DateTime&lt;/font&gt; CreatedOn;
. . &lt;font color=#7fffd4&gt;DateTime&lt;/font&gt; LastAccessed; }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
This would require that both pairs of business entity assemblies would need to have
a reference to the assembly. My plan was then to return from the webservice's webmethods
the interface rather than the object. For example.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[WebMethod] &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; IJob
GetJobById(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; id)
{ . . }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font size=2&gt;My plan was then bind the form controls to the properties
of the interface but among a couple of minor flaws in my plan, there was &lt;strong&gt;one
big&lt;/strong&gt; one... It appears that you &lt;em&gt;can not&lt;/em&gt; return an interface from
a web service. I assume do to it not being serialisable.&amp;nbsp;A little research later
it appears that a better way would be to would be to use a shared base class for the
business entities on both sides of the void, so to speak. So back to the drawing board
slightly..&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;h2&gt;Second Thoughts
&lt;/h2&gt;
&lt;p&gt;
So now I'm thinking I&amp;nbsp;need to create an abstract&amp;nbsp;base class for the objects
in the business entitiy assemblies&amp;nbsp;in both the client and the webservice to inherit
from. If I ensure the base classes implement the interfaces, then I&amp;nbsp;can still&amp;nbsp;bind
my controls to the interfaces properties. So ignoring the various properties of the
class I now have a bas class that implements the previosu
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;protected&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;abstract&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; BaseJob
: IJob { . . }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
So now the Job class in each business entity layer will inherit from the BaseJob abstract
class which implements the IJob interface.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; Job
: BaseJob { . . }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;font size=2&gt;So this means that now rather than just having a reference
to the assembly with the interfaces in for each business entity assembly I now have
a reference to the base class assembly too. Is this really the way I want to go?&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;To be continued...&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=eeefddc3-6c61-4adb-aad3-d43f78c94121" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,eeefddc3-6c61-4adb-aad3-d43f78c94121.aspx</comments>
      <category>.Net</category>
      <category>C#</category>
      <category>Inheritance</category>
      <category>Interfaces</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=728e6c3c-172c-4292-9d99-3e53560fb6d8</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=728e6c3c-172c-4292-9d99-3e53560fb6d8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As part of the preliminary research and design process for a prospective
new project at work one of the requirements will be for the application to provide
a webservice that can be consumed from a third party's Java application.
</p>
        <p>
So without further ado a quick .Net webservice was nocked up in C# with a single WebMethod.
The WebMethod would return a formatted string containing within it the value
passed in as a string parameter. The Webservice was deployed to localhost and tested
using the simple webform test that is present on a local instal.
</p>
        <p>
All good so far.
</p>
        <p>
Next is to build a small Java web project that can consume the webservice. So having
never written a Java application before, it's a quick trip to see Mr Google for a
working example of how to call a webservice from Java. ( <a href="http://www.duanewingett.info/2008/03/31/MyFirstJavaApp.aspx">See
My First Java App</a> ) Google thankfully turned up <a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=257552">David
Hobbs</a>' example "<span class="ArticleTopTitle" id="ctl00_ArticleTopHeader_ArticleTitle"><a href="http://www.codeproject.com/KB/XML/WSfromJava.aspx">How
to consume an ASP.NET webservice from Java via SOAP</a>"</span> on CodeProject. After
a an hour or after nocking up a quick Java webpage with an embedded applet
that will call the webservice and display the result, it should be a case of running
it and seeing it work like clockwork.... After all the whole idea of a webservice
is to platform unspecific, isn't it?....
</p>
        <p>
Well, I shouldn't really have expected miracles, should I? After a whole afternoon
of checking and double checking that the code was correct and using a free trial of <a href="http://www.prestosoft.com/edp_examdiffpro.asp">ExamDiff
Pro</a> to ensure that XML that the java code was out putting was exactly what
the XML that the server was expecting to receive I came to the conclusion that it
must be something perculiar to our network. The XML output was identical except for
the physical value of the parameter.
</p>
        <p>
So at the end of the day I was at a loss. I'm not sure if it is an error in the code,
or if the webservice expects different XML than what the description page offers up.
Or if there is a network security issue which isn't allowing communication between
the two applications. One of my .Net Windows applications calls a .Net webservice
which is built in the same way as this test one perfectly, and has done for the last
year! Event the third party representative was at a bit of a loss.
</p>
        <p>
So I am at a bit of a loss with this one. May be a fresh look in a new week will shed
some light. Who knows? If any one else has come accross this issue, and resolved or
not resolved it, please post and let me know your findings!
</p>
        <p>
          <hr />
        </p>
        <p>
        </p>
        <p>
          <font size="1">
            <strong>Postscript: #1</strong>
            <br />
          </font>I have just noticed on the botttom of David's CodeProject artical the following:
</p>
        <p>
          <em>
            <font color="#808080">
              <strong>Notes</strong>
              <br />
Some Java Virtual Machines (like the Microsoft one) only allow you to make a socket
connection to the same machine that hosts the Java class files. Therefore, if you're
using an applet like me, you will need to host the Java class files on the same machine
where the webservice resides.</font>
          </em>
        </p>
        <p>
I wonder if this has anything to do with the problem... Oh well, maybe tomorrow I'll
waste another fruitless afternoon trying to find out!! ;-)
</p>
        <p>
          <font size="1">
            <strong>Postscript: #2</strong>
          </font>
          <br />
Well after further investigation I haven't managed to determin the fault, but today
we tried a different approach and used the "Web Service proxy" object from the <strong>Business
Tier</strong> &gt; <strong>Web Services</strong> category in the New Gallery.
</p>
        <p>
          <img src="http://www.duanewingett.info/content/binary/NewGalleryWebService.jpg" border="0" />
        </p>
        <p>
We then followed the wizard and let it generate the code. The outputted code was tested
and hey presto!!
</p>
        <p>
So I guess this topic is closed for me now!
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=728e6c3c-172c-4292-9d99-3e53560fb6d8" />
      </body>
      <title>"Invalid Parameter" error when attempting to consume a .Net WebService from a Java application over network.</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</guid>
      <link>http://www.duanewingett.info/2008/03/31/InvalidParameterErrorWhenAttemptingToConsumeANetWebServiceFromAJavaApplicationOverNetwork.aspx</link>
      <pubDate>Mon, 31 Mar 2008 14:07:10 GMT</pubDate>
      <description>&lt;p&gt;
As part of the&amp;nbsp;preliminary research&amp;nbsp;and design process for a prospective
new project at work one of the requirements will be for the application to provide
a webservice that can be consumed from a third party's&amp;nbsp;Java application.
&lt;/p&gt;
&lt;p&gt;
So without further ado a quick .Net webservice was nocked up in C# with a single WebMethod.
The WebMethod would return a&amp;nbsp;formatted string&amp;nbsp;containing within it the value
passed in as a string parameter. The Webservice was deployed to localhost and tested
using the simple webform test that is present on a local instal.
&lt;/p&gt;
&lt;p&gt;
All good so far.
&lt;/p&gt;
&lt;p&gt;
Next is to build a small Java web project that can consume the webservice. So having
never written a Java application before, it's a quick trip to see Mr Google for a
working example of how to call a webservice from Java. ( &lt;a href="http://www.duanewingett.info/2008/03/31/MyFirstJavaApp.aspx"&gt;See
My First Java App&lt;/a&gt; ) Google thankfully turned up &lt;a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=257552"&gt;David
Hobbs&lt;/a&gt;' example "&lt;span class=ArticleTopTitle id=ctl00_ArticleTopHeader_ArticleTitle&gt;&lt;a href="http://www.codeproject.com/KB/XML/WSfromJava.aspx"&gt;How
to consume an ASP.NET webservice from Java via SOAP&lt;/a&gt;"&lt;/span&gt; on CodeProject. After
a&amp;nbsp;an hour or after nocking up a quick Java webpage&amp;nbsp;with an embedded applet
that will call the webservice and display the result, it should be a case of running
it and seeing it work like clockwork....&amp;nbsp;After all the whole idea of a webservice
is to platform unspecific, isn't it?....
&lt;/p&gt;
&lt;p&gt;
Well, I shouldn't really have expected miracles, should I? After a whole afternoon
of checking and double checking that the code was correct and using a free trial of &lt;a href="http://www.prestosoft.com/edp_examdiffpro.asp"&gt;ExamDiff
Pro&lt;/a&gt; to ensure that XML that&amp;nbsp;the java code was out putting was exactly what
the XML that the server was expecting to receive I came to the conclusion that it
must be something perculiar to our network. The XML output was identical except for
the physical value of the parameter.
&lt;/p&gt;
&lt;p&gt;
So at the end of the day I was at a loss. I'm not sure if it is an error in the code,
or if the webservice expects different XML than what the description page offers up.
Or if there is a network security issue which isn't allowing communication between
the two applications. One of my .Net Windows applications calls a .Net webservice
which is built in the same way as this test one perfectly, and has done for the last
year! Event the third party representative was at a bit of a loss.
&lt;/p&gt;
&lt;p&gt;
So I am at a bit of a loss with this one. May be a fresh look in a new week will shed
some light. Who knows? If any one else has come accross this issue, and resolved or
not resolved it, please post and let me know your findings!
&lt;/p&gt;
&lt;p&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;strong&gt;Postscript: #1&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;I have just noticed on the botttom of David's CodeProject artical the following:
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;font color=#808080&gt;&lt;strong&gt;Notes&lt;/strong&gt;
&lt;br&gt;
Some Java Virtual Machines (like the Microsoft one) only allow you to make a socket
connection to the same machine that hosts the Java class files. Therefore, if you're
using an applet like me, you will need to host the Java class files on the same machine
where the webservice resides.&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I wonder if this has anything to do with the problem... Oh well, maybe tomorrow I'll
waste another fruitless afternoon trying to find out!! ;-)
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;strong&gt;Postscript: #2&lt;/strong&gt;&lt;/font&gt;
&lt;br&gt;
Well after further investigation I haven't managed to determin the fault, but today
we tried a different approach and used the "Web Service proxy" object from the &lt;strong&gt;Business
Tier&lt;/strong&gt; &amp;gt; &lt;strong&gt;Web Services&lt;/strong&gt; category&amp;nbsp;in the New Gallery.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.duanewingett.info/content/binary/NewGalleryWebService.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
We then followed the wizard and let it generate the code. The outputted code was tested
and hey presto!!
&lt;/p&gt;
&lt;p&gt;
So I guess this topic is closed for me now!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=728e6c3c-172c-4292-9d99-3e53560fb6d8" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</comments>
      <category>.Net</category>
      <category>Java</category>
      <category>SOAP</category>
      <category>Web Services</category>
      <category>XML</category>
      <category>JDeveloper</category>
    </item>
  </channel>
</rss>