By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Accessing web service -- passing parameters..

P: n/a
Our vender provided us a web service:

1xyztest.xsd file...
------------------------------------
postEvent PostEventRequest
-------------------------------------
authetication authentication
eventname string
source string
ID string
date datetime
name string
parameters NameParameterValue
---------------------------------------

2authetication further nested into:
---------------------------------------
authentication authentication
--------------------------------------
principal string
credential string
---------------------------------------

3parameters further nested into
--------------------------------------
parameter namePrameterValue
name string
(grp1) choice
-------------------------------------
(grp1) choice
---------------------------------
stringvalue string
numericvalue numericvalue
booleanvalue boolean

---------------------------------------------------------------
I am trying to pass some parameters to this web service from test.aspx
webform....
The out it is expecting is something like this

HTML Code:
<authentication>
<principal>test</principal>
<creditial>test123</credential>
<authetication>
<parameters>
<name>text<name>
<value>testtext</value>
</parameters>
<name>numeric</name>
<value>56</value>
</parameters>Now I added a web referece to this webservice

Code:
dim xref as new xyztext.if I do sref.postevent
it is expecting 1st parameter as authetication as xyztest.authentication

same for parameters..

Code:
parameter() as xyztest.nameparameterValuePair------------------------------
I am not sure how to pass these parameters to web service.. to trigger a
webservice..
I would appreciate if someone could help me with this....

Thanks

Nov 1 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"amazon" <am****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Our vender provided us a web service:

1xyztest.xsd file...
If this is a standard SOAP web service, then the vendor should have supplied
you with a WSDL file, perhaps in addition to the XSD files. You should use
Add Web Reference in Visual Studio.NET to add a web reference to your
ASP.NET project. You will then be able to make calls to this web service
using standard code.

John
Nov 3 '06 #2

P: n/a
Thnaks John for answer....

Yes I do have wsdl file and added web reference to web service like normal
web service..

What I do not understand is:
How do I pass parameter of type authentication to a web service..
I know how to pass parameters as type string, integer etc...

"John Saunders" wrote:
"amazon" <am****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Our vender provided us a web service:

1xyztest.xsd file...

If this is a standard SOAP web service, then the vendor should have supplied
you with a WSDL file, perhaps in addition to the XSD files. You should use
Add Web Reference in Visual Studio.NET to add a web reference to your
ASP.NET project. You will then be able to make calls to this web service
using standard code.

John
Nov 3 '06 #3

P: n/a
"amazon" <am****@discussions.microsoft.comwrote in message
news:36**********************************@microsof t.com...
Thnaks John for answer....

Yes I do have wsdl file and added web reference to web service like normal
web service..

What I do not understand is:
How do I pass parameter of type authentication to a web service..
I know how to pass parameters as type string, integer etc...
In your Visual Studio project with the web reference, use Project->Show All
Files. If you expand the web reference, you'll find a file called
Reference.cs or Reference.vb. Take a look in that file, and see if VS hasn't
generated you an Authentication class you can use. Also, look to see what
the types are of the parameters to the proxy methods it has generated.

John
Nov 3 '06 #4

P: n/a
Thanks John again..

I am using visual studio 2005.. it doesn't seem to have that option..

There are three classes, I want to use:
1Authentication
2Post event(Imp class)
3name parameter value

I can do

Dim auth As ws.Authentication = New ws.Authentication()
Dim parameter As ws.NameParameterValuePair() = New
ws.NameParameterValuePair(2) {} (I am not sure how to declare this one?)
Dim postev As New ws.postevent

then I can assign:
auth.prinipal = "abc"
auth.credential = "xyz123"

Also, I want to pass two pair of parameters (not sure about how to asdsign
values to this also)
parameterWF(0).name = "string"
parameterWF(0).ItemElementName = "testX"

parameterWF(1).name = "string"
parameterWF(1).ItemElementName = "te**@email.com"

Now, if I want to pass parameters to the main class of the webservice:
I do:
postev.PostEvent(authentication as ws.authentication (I nned help in
passignn this), name as string,type as string,id as string, exdate as date,
parameter() as ws.nameparametervaluepair (I neeed help in passing this))

Now if everythingis string
I can do: postev.PostEvent("esfd", "abc", "asd" ,etc)

But How do I pass parameters, authentication values to a web service
"amazon" wrote:
Thnaks John for answer....

Yes I do have wsdl file and added web reference to web service like normal
web service..

What I do not understand is:
How do I pass parameter of type authentication to a web service..
I know how to pass parameters as type string, integer etc...

"John Saunders" wrote:
"amazon" <am****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Our vender provided us a web service:
>
1xyztest.xsd file...
If this is a standard SOAP web service, then the vendor should have supplied
you with a WSDL file, perhaps in addition to the XSD files. You should use
Add Web Reference in Visual Studio.NET to add a web reference to your
ASP.NET project. You will then be able to make calls to this web service
using standard code.

John

Nov 3 '06 #5

P: n/a
"amazon" <am****@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
Thanks John again..

I am using visual studio 2005.. it doesn't seem to have that option..
Which version of VS2005 are you using? I'm using the Professional Edition,
and it _does_ have that option. It's the first menu item on the Project
menu.

I'm using C#, which might be the difference.
If you can't look at the file directly (there's some neat stuff in there),
then take a look at your proxy class with Object Browser or the Class View.
John
Nov 3 '06 #6

P: n/a
I am using visual studio professional edition too..
I have five options at the top of the solution explorer:
1properties
2refresh
3Nest related files
4view designer
5copy website
6asp.net configuration

Could you please also help me with this:
There are three classes, I want to use:
1Authentication
2Post event(Imp class)
3name parameter value

I can do

Dim auth As ws.Authentication = New ws.Authentication()
Dim parameter As ws.NameParameterValuePair() = New
ws.NameParameterValuePair(2) {} (I am not sure how to declare this one?)
Dim postev As New ws.postevent

then I can assign:
auth.prinipal = "abc"
auth.credential = "xyz123"

Also, I want to pass two pair of parameters (not sure about how to asdsign
values to this also)
parameterWF(0).name = "string"
parameterWF(0).ItemElementName = "testX"

parameterWF(1).name = "string"
parameterWF(1).ItemElementName = "te**@email.com"

Now, if I want to pass parameters to the main class of the webservice:
I do:
postev.PostEvent(authentication as ws.authentication (I nned help in
passignn this), name as string,type as string,id as string, exdate as date,
parameter() as ws.nameparametervaluepair (I neeed help in passing this))

Now if everythingis string
I can do: postev.PostEvent("esfd", "abc", "asd" ,etc)

But How do I pass parameters, authentication values to a web service

Thank you so much and I really appreciate your help...


"John Saunders" wrote:
"amazon" <am****@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
Thanks John again..

I am using visual studio 2005.. it doesn't seem to have that option..

Which version of VS2005 are you using? I'm using the Professional Edition,
and it _does_ have that option. It's the first menu item on the Project
menu.

I'm using C#, which might be the difference.
If you can't look at the file directly (there's some neat stuff in there),
then take a look at your proxy class with Object Browser or the Class View.
John
Nov 3 '06 #7

P: n/a
"amazon" <am****@discussions.microsoft.comwrote in message
news:2D**********************************@microsof t.com...
>I am using visual studio professional edition too..
I have five options at the top of the solution explorer:
1properties
2refresh
3Nest related files
4view designer
5copy website
6asp.net configuration
What is in your Project menu? That's where I said that Show All Files was.

Also, have you looked at Class View or Object Browser?
postev.PostEvent(authentication as ws.authentication (I nned help in
passignn this), name as string,type as string,id as string, exdate as
date,
parameter() as ws.nameparametervaluepair (I neeed help in passing this))

Now if everythingis string
I can do: postev.PostEvent("esfd", "abc", "asd" ,etc)
Are you actually entering "as ws.authentication" in the web service call?
You don't do that. Just specify:

postev.PostEvent(authentication, name, type, id, exdate, parameter)

Are you saying that your problem has nothing in particular to do with the
fact that you're calling a web service, and instead has to do with the fact
that you don't know how to pass non-primmitive values to a method?

If this is so, you should have said so, and should have posted on one of the
VB.NET newsgroups.
John
Nov 4 '06 #8

P: n/a
Hi John,

First of all, I appologize for all the confusion created by my question..
and appreciate your responses....
What is in your Project menu? That's where I said that Show All Files was.
I am looking in solution explorer and I don't see it in there... I also have
vs 2003 and I see show all files option there but not in visual studio 2005..
Also, have you looked at Class View or Object Browser?
Oh!! I didn't know you can see classes for web services in above view..
Thank you very much.. .I see the classes I want to use.. .
>
postev.PostEvent(authentication as ws.authentication (I nned help in
passignn this), name as string,type as string,id as string, exdate as
date,
parameter() as ws.nameparametervaluepair (I neeed help in passing this))

Now if everythingis string
I can do: postev.PostEvent("esfd", "abc", "asd" ,etc)

Are you actually entering "as ws.authentication" in the web service call?
You don't do that. Just specify:
No.. I wasn't sure about how to pass type ws.authentication.. But now with
your help.. I created a function as type authentication(that I found it under
class view)
so I am passing just calling that class from web serive like
postev.PostEvent(auth(), .............)

and setting authentication parameters.

Private Function auth() As ws.Authentication
Dim authWF As ws_sghe_WF.Authentication = New ws.Authentication()
authWF.principal = "test"
authWF.credential = "testpwd"
Return auth
End Function

It is working fine and I am connecting to web service (Thanks to you)

postev.PostEvent(authentication, name, type, id, exdate, parameter)

Are you saying that your problem has nothing in particular to do with the
fact that you're calling a web service, and instead has to do with the fact
that you don't know how to pass non-primmitive values to a method?

If this is so, you should have said so, and should have posted on one of the
VB.NET newsgroups.
Actually I wasn't sure about what my problem was since I have absolutely no
documentation from our vendor.. but now I solve accessing problem with your
help and now having passing non-primitive data array type parameter() as
ws.nameparametervaluepair ..
If I do the same thing above that I did for authentication

Private Function parameter() As ws.NameParameterValuePair()
Dim parameter As ws.NameParameterValuePair()
parameter = New ws.NameParameterValuePair(2) {}

parameter(0).name = "string"
parameter(0).ItemElementName = "my*****@email.com"

parameter(1).name = "string"
parameter(1).ItemElementName = "my name"

Return parameter
End Function

I get following error:
Object reference not set to an instance of an object.

But as you said this is vb .net question.. I will post that in that forum

again, thanks for help..
>
John
Nov 5 '06 #9

P: n/a
"amazon" <am****@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
Hi John,

First of all, I appologize for all the confusion created by my question..
and appreciate your responses....
>What is in your Project menu? That's where I said that Show All Files
was.

I am looking in solution explorer and I don't see it in there... I also
have
vs 2003 and I see show all files option there but not in visual studio
2005..

Why are you looking in Solution Explorer when I ask you to look in your
Project menu???

Private Function parameter() As ws.NameParameterValuePair()
Dim parameter As ws.NameParameterValuePair()
parameter = New ws.NameParameterValuePair(2) {}

parameter(0).name = "string"
parameter(0).ItemElementName = "my*****@email.com"

parameter(1).name = "string"
parameter(1).ItemElementName = "my name"

Return parameter
End Function

I get following error:
Object reference not set to an instance of an object.

But as you said this is vb .net question.. I will post that in that forum
And the VB.NET answer is that you have created an array of
ws.NameParameterValuePair with dimension 2. You have not done anything to
set the values of the elements of the array.

Consider what it would mean if you did the exact same thing with an array of
Integer:

Dim parameter As Integer()
parameter = New Integer(2){}

' At this point, parameter(0) = 0 and parameter(1) = 0 because you
haven't set them to anything

If you did the same thing with an array of string, you'd see a similar
result:

Dim parameter As String()
parameter = New String(2){}

' At this point, parameter(0) = Nothing and parameter(1) = Nothing
' If you try:

Dim pl As Integer = parameter(0).Length

' Then you will get the same NullReferenceException
' The solution:

parameter(0) = "String"
Dim pl As Integer = parameter(0).Length
' pl is now 6

So, what you want to do in your function is:

Private Function parameter() As ws.NameParameterValuePair()
Dim parameter As ws.NameParameterValuePair()
parameter = New ws.NameParameterValuePair(2) {}

parameter(0) = New ws.NameParameterValuePair ' Allocate
first
parameter(0).name = "string"
parameter(0).ItemElementName = "my*****@email.com"

parameter(1) = New ws.NameParameterValuePair ' Allocate
first
parameter(1).name = "string"
parameter(1).ItemElementName = "my name"

Return parameter
End Function
John
Nov 5 '06 #10

P: n/a
Thnaks John..Thats exactly what I needed.. .

That solved my most of the problems..

I really appreciate the interst and efforts you took in helping me with
this..

"John Saunders" wrote:
"amazon" <am****@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
Hi John,

First of all, I appologize for all the confusion created by my question..
and appreciate your responses....
What is in your Project menu? That's where I said that Show All Files
was.
I am looking in solution explorer and I don't see it in there... I also
have
vs 2003 and I see show all files option there but not in visual studio
2005..


Why are you looking in Solution Explorer when I ask you to look in your
Project menu???

Private Function parameter() As ws.NameParameterValuePair()
Dim parameter As ws.NameParameterValuePair()
parameter = New ws.NameParameterValuePair(2) {}

parameter(0).name = "string"
parameter(0).ItemElementName = "my*****@email.com"

parameter(1).name = "string"
parameter(1).ItemElementName = "my name"

Return parameter
End Function

I get following error:
Object reference not set to an instance of an object.

But as you said this is vb .net question.. I will post that in that forum

And the VB.NET answer is that you have created an array of
ws.NameParameterValuePair with dimension 2. You have not done anything to
set the values of the elements of the array.

Consider what it would mean if you did the exact same thing with an array of
Integer:

Dim parameter As Integer()
parameter = New Integer(2){}

' At this point, parameter(0) = 0 and parameter(1) = 0 because you
haven't set them to anything

If you did the same thing with an array of string, you'd see a similar
result:

Dim parameter As String()
parameter = New String(2){}

' At this point, parameter(0) = Nothing and parameter(1) = Nothing
' If you try:

Dim pl As Integer = parameter(0).Length

' Then you will get the same NullReferenceException
' The solution:

parameter(0) = "String"
Dim pl As Integer = parameter(0).Length
' pl is now 6

So, what you want to do in your function is:

Private Function parameter() As ws.NameParameterValuePair()
Dim parameter As ws.NameParameterValuePair()
parameter = New ws.NameParameterValuePair(2) {}

parameter(0) = New ws.NameParameterValuePair ' Allocate
first
parameter(0).name = "string"
parameter(0).ItemElementName = "my*****@email.com"

parameter(1) = New ws.NameParameterValuePair ' Allocate
first
parameter(1).name = "string"
parameter(1).ItemElementName = "my name"

Return parameter
End Function
John
Nov 6 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.