|
Hi all,
I'm kind of a newby in webservices so I think this will be a simple question for you all.
I want to create an object on de webservice side (server) and return it to the application (client). The object on the client side must have the methods of the original object.
The code on the client side:
[webmethod]
public car createCar (string licenceplate)
{
car car = new car(licencePlate);
return car;
}
method in object class file (car.cs)
public string getLicencePlate
{
return this.licencePlate;
}
on the client side i want to ask the object its licenceplate. So: car.getLicencePlate();
But i can't see the methods. I only get the public attributes (and i don't want those)
Does anyone have a clear sample of returning Custom Type objects with WebServices or maybe give me a lesson in Serializable.
Ow.. I forgot... the client side is reacting asyn.
I hope someone can help me.
Kind regards,
Joost Voskuil
The Netherlands.
|
|
|
|
|
First, the method attributed with WebMethodAttribute must be on the server-side. You use the WSDL (contract) for the WebService to create a proxy object (i.e., an object that the client uses to proxy calls to the WebService).
As far as serialization goes, there is an example in your .NET Framework SDK. See <SDK>v1.0\Samples\Technologies\Serialization. You should also take a look at the System.Xml.Serialization . Many of the classes and methods in that namespace have example source code. It's just another way to control serialization that's designed more for XML. Just attributed classes and properties with various XML serialization attributes and have a public default constructor (a public constructor with no parameters).
Ultimately, serialization will get you farther (like with remoting), but I thought I'd mention XML serialization as an alternative when using WebServices (also handy to persist application settings and documents that you want other applications to be able to read easily).
Whichever way, just create an class that is attributed with SerializableAttribute (and optionally implements ISerializable , or that uses the attributes in System.Xml.Serialization . Pass that type as a parameter (or as a return value) in your WebService method and that's really all you need to do.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanx Heath,
What you mention helped me allot. Still figuring out the stuff, though. I have the system working now, but I’m certainly that it is al real quick and dirty solution. Do you have a clear example how you work?
Thanx in advanced
|
|
|
|
|
I don't, no, but there's plenty of examples here on CP and that you can find via google. Really, though, it's not difficult - just create an object that is serializable (or uses the attributes in the System.Xml.Serialization namespace and use that as your param or return type.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am developing a web application that will be viewed with Microsoft Internet Explorer 6 on a machine with touch screen. The touch screen is the only input/output device. There is no mouse or keyboard available for the end user. (Imagine an electronic information kiosk.)
Here's my current problem:
I am populating a table that contains square, "button-like" cells with information from a database. The buttons are styled using a CSS Style Sheet.
I need the entire square cell to be hyperlink sensitive to accomodate for the inaccuracies of a touch screen. Centered vertically and horizontally in the button should be a link text. Currently, my solution allows for everything but centering the text vertically.
I am using the following class to style a block hyperlink of size 75px by 75px:
A.selectCategoryButton {
display: block;
width: 75px;
height: 75px;
vertical-align: middle;
text-align: center;
text-decoration: none;
font-family: Verdana;
font-size: 12px;
color: white;
border: 1px solid black;
background-color: #0074E8;
}
An example of one cell in my table looks something like this:
<table>
<tr>
<td>
<a href="somelink" class="selectCategoryButton">
Link Text
</a>
</td>
</tr>
</table>
The result rendered in a browser is a 75px by 75px cell that is entirely "click-able" with all the properties defined in my class, BUT the text appears at the top of the button like this:
___________
| Link Text |
| |
| |
| |
|_________|
I think this has to do with the fact that the CSS vertical-align property can only be used with in-line objects and not block objects.
Any workarounds or other solutions? Feedback is greatly appreciated... This is a somewhat time sensitive project.
|
|
|
|
|
|
I haven't tried it, so this is no more than a swag, but is it possible to place the text within <P> tags and define the box characteristics (margins, padding, etc) for the P element to constrain the text to the center of the cell containing it?
"Your village called - <BR>They're missing their idiot."
|
|
|
|
|
Use padding to achieve what you want.
Regards,
Rohit Sinha
Browsy
Do not wait for leaders; do it alone, person to person.
- Mother Teresa
|
|
|
|
|
It's been awhile since I pressed the panic button. But I'm have trouble connecting to my SQL server from my classical ASP application. Here's the error:
Microsoft OLE DB Provider for SQL Server error '80004005'
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
/SomeDevFolder/login.asp, line 69
If you print the connection string to screen:
"Connection string: Provider=sqloledb; Data Source='XXX.XXX.XXX.XXX'; Initial Catalog='MyDatabase'; User ID='sa'; Password='secret'"
1. I want to emphasize that the ASP script works fine with one SQL server and not with another.
2. The SQL server I'm having trouble to connect to is the default instance.
3. Yes, I have checked and double checked: The SQL server is in "Mixed Mode" (authentication) - I have no idea what it has to do with trusted connection or not. I have supplied both username/password. What more do they want from me?
4. I used Query Analyzer to connect to the SQL server I'm having trouble with - using same connection string (user name and password) - it worked fine.
I doubt if it's has to do with my ASP code since connection to another server works, but, here's the code anyway:
oConn.ConnectionString = "Provider=sqloledb; Data Source='" & Application.Contents("sDbSource") & "'; Initial Catalog='" & Application.Contents("sDbInitialCatalog") & "'; User ID='" & Application.Contents("sDbUser") & "'; Password='" & Application.Contents("sDbPassword") & "'"
oConn.Open
Help!
|
|
|
|
|
Have you verified that your error isn't related to a permission problem at the IIS level (rather than the SQLServer level)?
It sounds like your request isn't making it to the database.
|
|
|
|
|
download it from http://himadrish.cjb.net
Himadrish Laha
|
|
|
|
|
'Open Save Cancel MoreInfo Dailog box' apperar any time I want to view my ASP.Net Code via internet explorer. Internet explorer 6, IIS are all runing in my Win2k system. Is there any additional configuration that I need to do in other to solve this problem.
With this Message box coming up any time I have not being able test my ASP.net page in internet explorer.
Thanks.
Cyril
|
|
|
|
|
Do you have the .NET Framework installed?
If yes then check in IIS to make sure the ASP.NET files are still registered (.aspx, .ascx, etc. etc.). .NET 1.0 would often loose the settings in IIS, 1.1 seems to have sorted that out.
regards,
Paul Watson
Bluegrass
South Africa
Brian Welsch wrote:
"blah blah blah, maybe a potato?" while translating my Afrikaans.
Crikey! ain't life grand?
|
|
|
|
|
heh
im trying to replace \r\n (newlines in a text area) with tags for a preview window and im going slightly mad
can anybody tell me what magic javascript incantation i should use in the:
dtext = text.replace("\r\n","<br>");
line?
thnx
"there is no spoon" biz stuff about me
|
|
|
|
|
try using dtext = text.replace("\r\n","\n");
or use dtext = text.replace(/\r|\n|\r\n/g, "");
I live to code.
|
|
|
|
|
i tried both and neither worked
im basically throeing up a new window that is supposed to show an html preview of what is typed into a textarea ... when the user hits the enter key a \r\n sequence is generated (i thought) and i need to replace that with <br> for formatting purposes
thnx for trying tho
"there is no spoon" biz stuff about me
|
|
|
|
|
sorry
my bad
it worked after i understood what u actually said to me
"there is no spoon" biz stuff about me
|
|
|
|
|
glad to have helped
I live to code.
|
|
|
|
|
Hello does anybody have any ideas on how I could put an iframe on the page and allow the user to resize it by dragging an edge (only one edge) just like a normal frame? Thanks in advance Jim.
Jim
|
|
|
|
|
This is out of the blue but have you considered putting an IFrame inside a frame? set the iframe to width=100% and have the frame as your border... I don't know if that will work or even if you want to use frames..
|
|
|
|
|
Thanks, for your reply. Unfortunately I cant use frames. I am using the iframe to display another page when a user clicks a link. I am showing the iframe when the link is displayed and hiding it when the user clicks a close button so its all inline to the page.
Jim
|
|
|
|
|
I think, that it could be possible to do this with JavaScript (but only on newer browsers...)
If you have IFRAME surround with four DIVs you can write script for resizing IFRAME using borders created by this four DIV elements...
|
|
|
|
|
Thanks for your reply. I have started to think along those lines now. Fortunately the website is on an intranet where internet explorer 6 is standard so I can use the latest scripting dom. My idea now is to have a control such as a div that the user can drag and have a dynamic property on the iframe that relates to the position of the div. Theres a usefull behaviour on Jon Udells site for moving and resizing html elements that will provide a usefull starter for me Andrew Mayo's resize.htc, a "behavior" for moving and resizing HTML elements[^]. p.s. I liked the popup article and may well be using it in future projects (once I've converted it to VB.NET) .
Jim
|
|
|
|
|
The best way I can think of is to relate my question to what codeproject does:
Remember Me?
After logging in, how does the system recognize me the next time without storing WhoIs data in the cookie? If I would store the developer_id one could easly make his own cookie as another developer. Storing a password is unsafe and I would like to avoid it.
Vote twice on sunday
When voting for an article, it is fair to only vote once. How can I ensure that? I looked in the codeprojects' cookie and didn't see any recollection of my past votes... Is there a database involved? can someone suggest a way to approach this issue?
Needs
I thought that it is wise to store a developer_id and alias in a cookie and that would help out when approaching FORMS throughout. With that, I would extract the necessary data from the DB - e.g. Email and "place" it where it is needed. But, as I mentioned, by just browsing the site, one can easily bake his own cookie with another existing developers' id and alias...
Encryption
If by now you are thinking why not use encryption, then do you know of a good encryption algorithm for ASP (NOT .NET) ?
Thank you.
|
|
|
|
|
Ok, I am still in need of help but this is what I have so far:
I have decided to encrypt the cookie data which holds only a developer_id and alias . using double encryption I can later compare if the data has been tampered with or not.
votes
This issue remains unresolved. How can I ensure that someone doesn't vote twice?
CP rules!
|
|
|
|