saidev

Hi,
I am new to C# and have a question about the Web Reference option. I love how easy it is that generate the proxy class for me but it seem that the proxy class is not generating what I want. Here is what I done so far, we have tested this web service using the same wsdl using Java and RoR web services client and they both return the excepted data. When I use C# Web reference option and drop in my wsdl url, one of the method return a 'struct like' thing(sorry for my lack of term, I'll show you some code to make sense of this).

The wsdl consists of two operations, getSimpleType and getSimpleTypeWithParam. They both suppose to return SimpleType object according to the service I wrote. But when C# I call getSimpleType I get return type of getSimpleTypeResponse and not SimpleType as excepted. On the other hand, getSimpleTypeWithParam return SimpleType like it was specified in the web service.


Current Code

SimpleTypeWebReference.SimpleTypeRetrievalService serv = SimpleTypeWebReference.SimpleTypeRetrievalService();
SimpleTypeWebReference.getSimpleTypeResponse simpleTypeResponse = serv.getSimpleType();
simpleTypeResponse.@return.number;
simpleTypeResponse@return.word;





I like to do this - but it won't compile

SimpleTypeWebReference.SimpleTypeRetrievalService serv = SimpleTypeWebReference.SimpleTypeRetrievalService();
SimpleTypeWebReference.SimpleType simpleType = serv.getSimpleType();
simpleType.number;
simpleType.word;




I posted the wsdl below that is generated by Axis2. Thank you. I hope this is something I overlook as I'm a newbie ini C#.




Code Snippet

<wsdl:definitions targetNamespace="http://service.thecompany.com">
<wsdl:documentation>SimpleTypeRetrievalService</wsdl:documentation>
-
<wsdl:types>
-
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.thecompany.com/xsd">
-
<xs:complexType name="SimpleType">
-
<xs:sequence>
<xs:element minOccurs="0" name="number" type="xs:int"/>
<xs:element minOccurs="0" name="word" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
-
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.thecompany.com">
-
<xs:element name="getSimpleTypeResponse">
-
<xs:complexType>
-
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:SimpleType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
-
<xs:element name="getSimpleTypeWithParam">
-
<xs:complexType>
-
<xs:sequence>
<xs:element minOccurs="0" name="a" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
-
<xs:element name="getSimpleTypeWithParamResponse">
-
<xs:complexType>
-
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:SimpleType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
-
<xs:element name="runTestResponse">
-
<xs:complexType>
-
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="runTestRequest"/>
-
<wsdl:message name="runTestResponse">
<wsdl:part name="parameters" element="ns1:runTestResponse"/>
</wsdl:message>
-
<wsdl:message name="getSimpleTypeWithParamRequest">
<wsdl:part name="parameters" element="ns1:getSimpleTypeWithParam"/>
</wsdl:message>
-
<wsdl:message name="getSimpleTypeWithParamResponse">
<wsdl:part name="parameters" element="ns1:getSimpleTypeWithParamResponse"/>
</wsdl:message>
<wsdl:message name="getSimpleTypeRequest"/>
-
<wsdl:message name="getSimpleTypeResponse">
<wsdl:part name="parameters" element="ns1:getSimpleTypeResponse"/>
</wsdl:message>
-
<wsdl:portType name="SimpleTypeRetrievalServicePortType">
-
<wsdl:operation name="runTest">
<wsdl:input message="ns1:runTestRequest" wsaw:Action="urn:runTest"/>
<wsdl:output message="ns1:runTestResponse" wsaw:Action="urn:runTestResponse"/>
</wsdl:operation>
-
<wsdl:operation name="getSimpleTypeWithParam">
<wsdl:input message="ns1:getSimpleTypeWithParamRequest" wsaw:Action="urn:getSimpleTypeWithParam"/>
<wsdl:output message="ns1:getSimpleTypeWithParamResponse" wsaw:Action="urn:getSimpleTypeWithParamResponse"/>
</wsdl:operation>
-
<wsdl:operation name="getSimpleType">
<wsdl:input message="ns1:getSimpleTypeRequest" wsaw:Action="urn:getSimpleType"/>
<wsdl:output message="ns1:getSimpleTypeResponse" wsaw:Action="urn:getSimpleTypeResponse"/>
</wsdl:operation>
</wsdl:portType>
-
<wsdl:binding name="SimpleTypeRetrievalServiceSOAP11Binding" type="ns1:SimpleTypeRetrievalServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-
<wsdl:operation name="runTest">
<soap:operation soapAction="urn:runTest" style="document"/>
-
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleTypeWithParam">
<soap:operation soapAction="urn:getSimpleTypeWithParam" style="document"/>
-
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleType">
<soap:operation soapAction="urn:getSimpleType" style="document"/>
-
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-
<wsdl:binding name="SimpleTypeRetrievalServiceSOAP12Binding" type="ns1:SimpleTypeRetrievalServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-
<wsdl:operation name="runTest">
<soap12:operation soapAction="urn:runTest" style="document"/>
-
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleTypeWithParam">
<soap12:operation soapAction="urn:getSimpleTypeWithParam" style="document"/>
-
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleType">
<soap12:operation soapAction="urn:getSimpleType" style="document"/>
-
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
-
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-
<wsdl:binding name="SimpleTypeRetrievalServiceHttpBinding" type="ns1:SimpleTypeRetrievalServicePortType">
<http:binding verb="POST"/>
-
<wsdl:operation name="runTest">
<http:operation location="SimpleTypeRetrievalService/runTest"/>
-
<wsdl:input>
<mime:content type="text/xml" part="runTest"/>
</wsdl:input>
-
<wsdl:output>
<mime:content type="text/xml" part="runTest"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleTypeWithParam">
<http:operation location="SimpleTypeRetrievalService/getSimpleTypeWithParam"/>
-
<wsdl:input>
<mime:content type="text/xml" part="getSimpleTypeWithParam"/>
</wsdl:input>
-
<wsdl:output>
<mime:content type="text/xml" part="getSimpleTypeWithParam"/>
</wsdl:output>
</wsdl:operation>
-
<wsdl:operation name="getSimpleType">
<http:operation location="SimpleTypeRetrievalService/getSimpleType"/>
-
<wsdl:input>
<mime:content type="text/xml" part="getSimpleType"/>
</wsdl:input>
-
<wsdl:output>
<mime:content type="text/xml" part="getSimpleType"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-
<wsdl:service name="SimpleTypeRetrievalService">
-
<wsdl:port name="SimpleTypeRetrievalServiceSOAP11port_http" binding="ns1:SimpleTypeRetrievalServiceSOAP11Binding">
<soap:address location="http://localhost:8085/axis2/services/SimpleTypeRetrievalService"/>
</wsdl:port>
-
<wsdl:port name="SimpleTypeRetrievalServiceSOAP12port_http" binding="ns1:SimpleTypeRetrievalServiceSOAP12Binding">
<soap12:address location="http://localhost:8085/axis2/services/SimpleTypeRetrievalService"/>
</wsdl:port>
-
<wsdl:port name="SimpleTypeRetrievalServiceHttpport" binding="ns1:SimpleTypeRetrievalServiceHttpBinding">
<http:address location="http://localhost:8085/axis2/services/SimpleTypeRetrievalService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



Re: .NET Framework Networking and Communication wsdl reading problem when I use Web Reference to read it

OmegaMan

If you feel that the WSDL is wrong, either change the generated code in reference.cs, or fat finger the WSDL and retest until you get what you think you need. I have had to do that to get my .net application talking nicely with third party web services. (You may want to override the proxy class or create your own code, so that a regeneration does not delete all your handywork). I have in the past tested third party applications in perl to see raw messages back and forth and compare them. I find the non Microsoft web services don't play well with Microsoft, such as sending back unexpected Xml token, etc...so this in my mind is not unusual.

Note reference.cs is a hidden file, here is how to view hidden files which I detail on my blog entitled Where are the Hidden Files using Visual Studio 2005 . Good Luck and HTH