Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / April 2004

Tip: Looking for answers? Try searching our database.

Proxy class not reading data returned in SOAP response

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jared - 28 Apr 2004 04:44 GMT
I'm trying to create a .NET client to consume a Java web service.  The
company that owns the web service does not publish a WSDL, but they do
publish an API document with examples of each supported request and
its corresponding response.

I've manually created a WSDL file based on their examples, and
generated a proxy class using WSDL.EXE.  The proxy class appears to
send a valid request because I can see a valid response coming back
using a network sniffer.  However, when the proxy class calls
Invoke(), it returns an object[] of the correct length, but with each
element null.

------------------------------------------------------
Here's the SOAP response I'm getting from the server (some data
changed to protect the innocent):

<?xml version="1.0" encoding="UTF-8"?>
<?Some_Company_API version="1.0"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
 <SOAP-ENV:Body>
   <m:TheResponse xmlns:m="Some API">
     <element1 xsi:type="xsd:string">some data</element1>
     <element2 xsi:type="xsd:string">some more data</element2>
   </m:TheResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
------------------------------------------------------

------------------------------------------------------
Here's the method of the proxy class I'm calling:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Login",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("element1")]
public string Login(string param1, string param2, string param3, out
string element2) {
object[] results = this.Invoke("Login", new object[] {
       param1,
       param2,
       param3});
element2 = ((string)(results[1]));
return ((string)(results[0]));
}
------------------------------------------------------

If I analyze results[] in breakmode, it has a length of 2, but each
element is null.

Is there something special I need to do to the proxy class to get it
to read the returned data?

TIA

Jared
Dino Chiesa [Microsoft] - 28 Apr 2004 08:02 GMT
yes, I think you need to set your RequestNamespace and ResponseNamespace to
"Some API"
not http://tempuri.org.

-Dino

> I'm trying to create a .NET client to consume a Java web service.  The
> company that owns the web service does not publish a WSDL, but they do
[quoted text clipped - 30 lines]
> ------------------------------------------------------
> Here's the method of the proxy class I'm calling:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.o
rg/Login",
> RequestNamespace="http://tempuri.org/",
> ResponseNamespace="http://tempuri.org/",
[quoted text clipped - 21 lines]
>
> Jared
Jared - 28 Apr 2004 20:17 GMT
> yes, I think you need to set your RequestNamespace and ResponseNamespace to
> "Some API"
> not http://tempuri.org.
>
> -Dino

Dino,

I've updated the method attributes as shown below.  I tried it with
and without setting the "ResponseElementName" param.  It still fails
to populate results[], even though I'm still seeing a valid response
with my network sniffer.

----------------------------------------------------
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Login",
 ResponseElementName="LoginResponse",
 RequestNamespace="Some API",
 ResponseNamespace="Some API",
 Use=System.Web.Services.Description.SoapBindingUse.Literal,
 ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("element1")]
public string Login(string param1, string param2, string param3, out
string element2) {
 object[] results = this.Invoke("Login", new object[] {
    param1,
    param2,
    param3});
 element2 = ((string)(results[1]));
 return ((string)(results[0]));
}
----------------------------------------------------

----------------------------------------------------
Is there anything wrong with my class attributes?

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="SomeApiSoap",
Namespace="http://tempuri.org/")]
public class SomeApi :
System.Web.Services.Protocols.SoapHttpClientProtocol {
 ...
}
----------------------------------------------------

Thanks again,

Jared
Jared Jensen - 28 Apr 2004 22:03 GMT
>> yes, I think you need to set your RequestNamespace and
>> ResponseNamespace to "Some API"
[quoted text clipped - 46 lines]
>
> Jared

Here's my own answer based on the following post:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8
&safe=off&threadm=avmXa.5874%24Ye.5664%40fed1read02&rnum=4&prev=/groups%
3Fq%3Dnull%2520%2522SOAP%253A%253ALite%2522%26num%3D30%26hl%3Den%26lr%
3D%26ie%3DUTF-8%26oe%3DUTF-8%26safe%3Doff%26sa%3DN%26tab%3Dwg

(Note that the web service is Perl SOAP::Lite)

-----------------------------------------------------------------
[System.Web.Services.Protocols.SoapDocumentMethodAttribute
("http://tempuri.org/Login",
ResponseElementName="LoginResponse",
RequestNamespace="Some API",
ResponseNamespace="Some API",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)
]
[return: System.Xml.Serialization.SoapElementAttribute("element1")]
public string Login(string param1, string param2, string param3, out
string element2) {
...
}

The fixes were:

1) Use SoapBindingUse.Encoded instead of Literal
2) Use Serialization.SoapElementAttribute("element1") instead of
XmlElementAttribute("element1")
-----------------------------------------------------------------
Dino Chiesa [Microsoft] - 30 Apr 2004 15:32 GMT
Great, glad you were able to solve it.  sorry I couldn't be more helpful.
SOAP::Lite is nice but I think its lack of WSDL support means that
development is trickier.

ps: that URL was:
http://tinyurl.com/3ao5b

-Dino

> >> yes, I think you need to set your RequestNamespace and
> >> ResponseNamespace to "Some API"
[quoted text clipped - 79 lines]
> XmlElementAttribute("element1")
> -----------------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.