D
David
Hi all,
I am having a problem trying to call my web services from an activex.
I have two webservices, one on an external web server, one on an internal
one. Basically, the client will be calling a page from the external server,
the activex will download a file and transfer it to the other webservice on
the intranet server.
We need to do it this way as the firewall rules are very strong and almost
impossible to change. However, the client is happy to allow this method, if
only I can get it to work.
Code is below...
==============================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
// csc un.cs
// csc /t:library /out:Un.DLL un.cs
namespace GetPrePop
{
public class MyPrePop : Control
{
public static void Main(string[] m)
{
string FileName = "testfile.txt";
GetFile(FileName);
PushFile(FileName);
Form f = new Form();
MyPrePop t = new MyPrePop();
t.Dock = DockStyle.Fill;
f.Controls.Add(t);
Application.Run(f);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Azure), ClientRectangle);
e.Graphics.DrawLine(Pens.Blue,
new Point(ClientRectangle.Width, ClientRectangle.Height),
new Point(0, 0));
}
private static void GetFile(string FileName)
{
FetchPrePop.fetchPrePop fpp = new GetPrePop.FetchPrePop.fetchPrePop();
//fpp.GetFile(FileName);
if (!File.Exists(FileName))
{
BinaryWriter binWriter = new BinaryWriter(File.Open(FileName,
FileMode.CreateNew, FileAccess.ReadWrite));
binWriter.Write(fpp.GetFile(FileName));
binWriter.Close();
}
}
private static void PushFile(string FileName)
{
System.IO.BinaryReader br = new
System.IO.BinaryReader(System.IO.File.Open(FileName,
System.IO.FileMode.Open, System.IO.FileAccess.Read));
br.BaseStream.Position = 0;
byte[] buffer = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
ReceivePrePop.receivePrePop rpp = new
GetPrePop.ReceivePrePop.receivePrePop();
rpp.PutFile(buffer, FileName);
br.Close();
}
}
}
==============================================
This gets compiled into a DLL and opened in the browser with...
<object id=t classid="http:GetPrePop8.DLL#GetPrePop.MyPrePop" height="300"
width="300" VIEWASTEXT>
</object>
Now, I get the picture (just a line in a bluish box), but checking my web
logs, the calls to the webservice (in GetFile and PushFile) are not
happening.
The two webservices are registered. I have tested the webservices with a
console application (running the identical code here but removing the paint
and the last 5 lines in the Main())
Are there security issues in calling webservices from within the control? Do
I need to build the control a different way?
Just for info, VS is compiling it as...
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702
/errorreportrompt /warn:4 /defineEBUG;TRACE
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /filealign:512 /optimize- /outbj\Debug\GetPrePop8.dll
/target:library Class1.cs Properties\AssemblyInfo.cs
Properties\Settings.Designer.cs "Web References\FetchPrePop\Reference.cs"
"Web References\ReceivePrePop\Reference.cs"
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I am having a problem trying to call my web services from an activex.
I have two webservices, one on an external web server, one on an internal
one. Basically, the client will be calling a page from the external server,
the activex will download a file and transfer it to the other webservice on
the intranet server.
We need to do it this way as the firewall rules are very strong and almost
impossible to change. However, the client is happy to allow this method, if
only I can get it to work.
Code is below...
==============================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
// csc un.cs
// csc /t:library /out:Un.DLL un.cs
namespace GetPrePop
{
public class MyPrePop : Control
{
public static void Main(string[] m)
{
string FileName = "testfile.txt";
GetFile(FileName);
PushFile(FileName);
Form f = new Form();
MyPrePop t = new MyPrePop();
t.Dock = DockStyle.Fill;
f.Controls.Add(t);
Application.Run(f);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Azure), ClientRectangle);
e.Graphics.DrawLine(Pens.Blue,
new Point(ClientRectangle.Width, ClientRectangle.Height),
new Point(0, 0));
}
private static void GetFile(string FileName)
{
FetchPrePop.fetchPrePop fpp = new GetPrePop.FetchPrePop.fetchPrePop();
//fpp.GetFile(FileName);
if (!File.Exists(FileName))
{
BinaryWriter binWriter = new BinaryWriter(File.Open(FileName,
FileMode.CreateNew, FileAccess.ReadWrite));
binWriter.Write(fpp.GetFile(FileName));
binWriter.Close();
}
}
private static void PushFile(string FileName)
{
System.IO.BinaryReader br = new
System.IO.BinaryReader(System.IO.File.Open(FileName,
System.IO.FileMode.Open, System.IO.FileAccess.Read));
br.BaseStream.Position = 0;
byte[] buffer = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
ReceivePrePop.receivePrePop rpp = new
GetPrePop.ReceivePrePop.receivePrePop();
rpp.PutFile(buffer, FileName);
br.Close();
}
}
}
==============================================
This gets compiled into a DLL and opened in the browser with...
<object id=t classid="http:GetPrePop8.DLL#GetPrePop.MyPrePop" height="300"
width="300" VIEWASTEXT>
</object>
Now, I get the picture (just a line in a bluish box), but checking my web
logs, the calls to the webservice (in GetFile and PushFile) are not
happening.
The two webservices are registered. I have tested the webservices with a
console application (running the identical code here but removing the paint
and the last 5 lines in the Main())
Are there security issues in calling webservices from within the control? Do
I need to build the control a different way?
Just for info, VS is compiling it as...
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702
/errorreportrompt /warn:4 /defineEBUG;TRACE
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
/reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /filealign:512 /optimize- /outbj\Debug\GetPrePop8.dll
/target:library Class1.cs Properties\AssemblyInfo.cs
Properties\Settings.Designer.cs "Web References\FetchPrePop\Reference.cs"
"Web References\ReceivePrePop\Reference.cs"
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available