0

First time trying to use webservices. I am using VS2005 and trying to call a webservice function. I added my webreference to the WSDL, got my autogenerated code.

I am able to call it with no errors/exceptions but I get nothing back from the service function. I packet sniffed the network traffic when I ran my code and saw that the webservice actually sent back the data it was supposed to, I just never recieved it in my code below

    Dim proxy As New MyServer.MyService
    Dim response As New Object()
    response = proxy.getAllThings(Nothing)

In the WSDL it says it requires Object as parameter and returns Object. Also tried:
Dim response As New Object and
Dim response As String=""

Response is always Nothing/Null

The sniffed data shows a plaintext SOAP envelope which is what I was expecting 'response' to contain.

Sniffed Data sent from webservice to my computers IP address:

    Server: Apache-Coyote/1.1
    Content-Type: text/xml;charset=utf-8
    Transfer-Encoding: chunked
    Date: Mon, 23 Apr 2012 08:26:01 GMT
    321
    <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><cmp:things xmlns:cmp="http://cmp.com"><cmp:thing><cmp:id>10</cmp:id><cmp:name>ASM</cmp:name></cmp:thing><cmp:thing><cmp:id>1</cmp:id><cmp:name>CHP</cmp:name></cmp:thing><cmp:thing><cmp:id>11</cmp:id><cmp:name>UDB</cmp:name></cmp:thing><cmp:thing><cmp:id>8</cmp:id><cmp:name>GKH</cmp:name></cmp:thing><cmp:thing><cmp:id>5</cmp:id><cmp:name>GGW</cmp:name></cmp:thing><cmp:thing><cmp:id>6</cmp:id><cmp:name>LRZ</cmp:name></cmp:thing><cmp:thing><cmp:id>7</cmp:id><cmp:name>MRN</cmp:name></cmp:thing><cmp:thing><cmp:id>2</cmp:id><cmp:name>KBV</cmp:name></cmp:thing><cmp:thing><cmp:id>3</cmp:id><cmp:name>CXE</cmp:name></cmp:thing></cmp:things></soapenv:Body></soapenv:Envelope>
    0

This sniffed data never shows up in 'response'

I used http://msdn.microsoft.com/en-us/library/aa275675%28v=sql.80%29.aspx as an example.

Any help would be greatly appreciated.

Edit: 'response' should contain the data from the result of the webservice call shouldnt it?

Dorf
  • 71
  • 9
  • What datatype is getAllThings returning? – Milee Apr 23 '12 at 07:46
  • its not returning anything type is Nothing – Dorf Apr 23 '12 at 07:57
  • Then what are you trying to store in variable 'response' and you also mentioning that it returns an object acc. to the WSDL ... can you edit your question or something? – Milee Apr 23 '12 at 08:06
  • Sorry if Im not being clear, first time trying to use webservices. It says it returns Object I have tried declaring the return value as Object but it doesnt return anything Nothing/Null. – Dorf Apr 23 '12 at 08:22
  • What are you expecting as output? Atleast you would be knowing that... and if you dont want any output... you shouldnot store it in response object... – Milee Apr 23 '12 at 08:25
  • Just added the data that I was hoping to get. – Dorf Apr 23 '12 at 08:32
  • Oh k... Are you actually passing Nothing as an object when calling getAllThings(Nothing)? – Milee Apr 23 '12 at 08:42
  • Yes. I was told that that function did not require a parameter. But the WSDL specifies there to be an Object as a parameter. getAllThings(GetAllThings1 as Object) as Object – Dorf Apr 23 '12 at 08:45
  • then create an Object in a similar way as response and send it... But i dont understand what are you trying to achieve. May be you should check the same with the person who wrote the webservice. – Milee Apr 23 '12 at 08:49
  • Going to be quite some time before I can talk to him again, but he directed me to this service that has a bunch of functions. He said NONE of them require parameters. They are supposed to just send back a list of different types of things. My guess is the WSDL is autogenerated and just sticks an Object in the parameters if none are needed. But either way, when I call it with Nothing, the function sends the data I want over the ethernet, I see this data in a packetsniff, but that data never makes its way into reponse. I dont think its a problem with the parameter. Thanks for your help so far – Dorf Apr 23 '12 at 08:54
  • What Im trying to acheive is to get that data I see in the packet sniff into my program. Maybe the data doesnt go to 'response' but I have to access it from the proxy variable or something? Im a total newbie here remember. – Dorf Apr 23 '12 at 08:57
  • hmm... it is still unclear where your data is getting stored or how is it being retrived... because there can be chances that you have a problem at Database side or web service side ... mite be needing a bit of the web service method code ... alteast the algo... :) – Milee Apr 23 '12 at 09:02
  • I think the service is running fine. As soon as my code is called I see the data packets from the service return the above SOAP envelope to my computers IP address. It just never makes it to the 'response' variable. – Dorf Apr 23 '12 at 09:06
  • And obviously when you are passing Nothing,you will get Nothing in return acc. to what you are telling – Milee Apr 23 '12 at 09:17
  • Maybe this is where I am getting confused. Since I was told it doesnt require a parameter I stuck a Nothing in there. The service IS sending the complete SOAP envelope that I posted in the question above over the ethernet. So am I supposed to be putting some kind of formatting requirements instead of 'Nothing' in there? and therefore I didnt specify which of the fields I wanted and therefore it gave me none of the fields from the SOAP envelope? – Dorf Apr 23 '12 at 09:24
  • @Dorf..... try using XmlFormatter class and then print it :) if you think that is the problem. – Milee Apr 24 '12 at 05:03
  • That soap envelope never makes it into the generated webreference class. The only way I can see that envelope is using a packet sniffer to see the data flowing on the network. Something is stopping that soap/xml data from being seen by my program/class. I havent got a clue what it is, I am guessing its some kind of setting but there appears to be no special required settings in the sample code from MS. – Dorf Apr 24 '12 at 05:26
  • hmm then may be some user setting from the programmer's side... have a talk with the web service guy ... :) and try to retrieve this sniffed xml and convert it using a formatter and display its data... though i dont think it should be that complex... check the app.config file. Maybe some environment settings are not suitable for you. – Milee Apr 24 '12 at 05:28
  • So even though the data from the service reaches my computer and does not make itself into my program/webreference output, you think it is a problem with the service? Not a problem with my client Im writing? – Dorf Apr 24 '12 at 05:53
  • Oh k if you think so ... instead of passing nothing,try creating a class and sending those values like class car{ public string color;public int model;} psvm(string args[]){ car c=new car(); c.color="white"; c.model=123; //call service here} ... your method seems to be accepting just any class object. so, while receving try creating object of the same class and receving it. If it doesnt make any difference then it is ofcourse a problem from your web service side... i think it is mainly the binding they are using or some environment settings. – Milee Apr 24 '12 at 05:59

1 Answers1

1

Installed VS2010 express on a different computer and connected to the service and I got an error message. Basically the response from the service does not match the WSDL. Dont know why VS2005 didnt give me any errors.

It is a service in production being consumed by a java client, apparently it doesnt care about the mismatch.

Dorf
  • 71
  • 9