return "hello world"

I've created a simple webservice which works in a browser, but how can i get it to return the string of "Hello World" into a vb.net application?
[155 byte] By [Steve-B3] at [2007-12-22]
# 1
Have you tried the webservice example in the help, it shows you how to create a webservice to do temperature conversion, then goes on to show you how you would consume that web service
JanHyde at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2

Ok, solved it.

I want to send the following back as a result from the webservice to the application but get told it's not allowed as it's not a string:

Entity.quotenum
Entity.Company name

Return Entity

How can i achieve this?

Steve-B3 at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3

you need to return Entity, assuming Entity is an object.

so instead of:

public string SomeMethod() { .. }

the signature should be:

public Entity SomeMethod() { .. }

its all to do with the return type in this case. Entity would not be a string but an object of type - you guessed it - Entity

ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 4

Erm, ok. i get that, but where does it go?

i'm using the following at the mo:

Public Function Svc1(ByVal DocumentName As String) As Calculator.ServerDocResult

How do i return it?
Is it just the same?

Return Svc1 ?

Apologies if it's simple but i can't find anything on this

Steve-B3 at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 5

to me, that code there is telling me you are returning back Calculator.ServerDocResult, correct?

SVC1 is the NAME of the function, not the return type.

so I guess....

public function Svc1(ByVal DocumentName As String) As Calculator.ServerDocResult

'Do stuff here with ServerDocResult object

return theServerDocResult

End function

have you ever developed in VB.NET? It's the same for webservices (to a certain extent I guess). :-)

so if I had a class called "Person". a Person has many attributes (properties)

  • Arms

  • Legs

  • Eyes

    if I wanted to return "A person" back to the caller from the webservice:

    public function DoGetMeAPerson(string thePersonName) As Person

    Dim thePerson as New Person()

    thePerson.Name = thePersonName

    return thePerson

    end function

    simple example, simple OO example I guess.

    in the webservice, you are creating a person object and giving this person a name, then returning this person object.

    The same would apply for your ServerDocResult.

    does this help make things clearer?

  • ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
    # 6
    That's what i thought, but when i run the application it times out.
    Steve-B3 at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
    # 7

    any errors?

    At what part does it time out?

    Code from either end (caller and webservice) would be better for us to assist you

    ahmedilyas at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
    # 8

    Here's the web service code i use:

    <WebMethod()> _

    Public Function DocumentSvc1(ByVal DocumentName As String, ByVal Entities As Calculator.Entity) As ServerDocResult

    DocumentSvc1.EmailTo = S@s.com
    DocumentSvc1.Name = "SR"

    Return DocumentSvc1

    End Function

    And for the application:

    Dim Entity As New StevesWebSvcTest.uk.co.<domain>.www.Entity

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Entity.CompanyName =
    "Seegfe"
    Entity.ContactName = "Steve"

    Label1.Text = Submit.B3DocumentSvc1("ServerDoc1", Entity).EmailFromAddress

    End Sub

    It times out on the Label1.Text part.

    Steve-B3 at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
    # 9

    Please use wsdl.exe tool to generate the client ofr your webservice:

    wsdl.exe http://hostname/service.asmx /language:vb

    It willl generate a vb wrappes to call the service, compile the code into your client app, and use it.

    Thanks,

    Elena

    ElenaKharitidi at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

    .NET Development

    Site Classified