Solved

Instantiating a web service error Cannot implicit convert type

Posted on 2013-12-18
3
667 Views
Last Modified: 2013-12-18
I'm using c#, .net.  When I instantiate this service:

viviendo.ResidentService RS= new viviendo.ResidentService();
viviendo.PizzaSales RSA= new viviendo.PizzaSales();

Then try to access it:
try
{
RSA = RS.getCustomer("123456789");
}
I get error:  Cannot implicitly convert type Viviendo.CustomerResult to PizzaSales

I've been stuck on this for a few days.  Any help would be appreciated.  I need to access the data returned for the data element FacName.
Thanks.

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="https://viviendo.mysite.net/Greek/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="https://viviendo.mysite.net/Greek/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:s="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Provide Customer Lookup</wsdl:documentation>
<wsdl:types>
<s:schema targetNamespace="https://viviendo.mysite.net/Greek/" elementFormDefault="qualified">
<s:element name="getCustomer">
<s:complexType>
<s:sequence>
<s:element name="MySchoolid" type="s:string" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element><s:element name="getCustomerResponse">
<s:complexType>
<s:sequence><s:element name="getCustomerResult" type="tns:ABCDPatron" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element><s:complexType name="ABCDPatron">
<s:sequence>
<s:element name="MYSCHOOLID" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="FirstName" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="LastName" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="Contracts" type="tns:ArrayOfPizzaSales" maxOccurs="1" minOccurs="0"/>
<s:element name="Exception" type="s:string" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfPizzaSales">
<s:sequence>
<s:element name="PizzaSales" type="tns:PizzaSales" maxOccurs="unbounded" minOccurs="0" nillable="true"/>
</s:sequence>
</s:complexType>
<s:complexType name="PizzaSales">
<s:sequence>
<s:element name="Term" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="FacType" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="FacName" type="s:string" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="getCustomerSoapIn">
<wsdl:part name="parameters" element="tns:getCustomer"/>
</wsdl:message>
<wsdl:message name="getCustomerSoapOut">
<wsdl:part name="parameters" element="tns:getCustomerResponse"/></wsdl:message><wsdl:portType name="ResidentServiceSoap">
<wsdl:operation name="getCustomer"><wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Information Lookup</wsdl:documentation>
<wsdl:input message="tns:getCustomerSoapIn"/><wsdl:output message="tns:getCustomerSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ResidentServiceSoap" type="tns:ResidentServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getCustomer">
<soap:operation style="document" soapAction="https://viviendo.mysite.net/Greek/getCustomer"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output><soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ResidentServiceSoap12" type="tns:ResidentServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getCustomer">
<soap12:operation style="document" soapAction="https://viviendo.mysite.net/Greek/getCustomer"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ResidentService">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Provide Customer Lookup</wsdl:documentation>
<wsdl:port name="ResidentServiceSoap" binding="tns:ResidentServiceSoap"><soap:address location="https://viviendo.mysite.net/abcd/ws/residentservice.asmx"/>
</wsdl:port><wsdl:port name="ResidentServiceSoap12" binding="tns:ResidentServiceSoap12">
<soap12:address location="https://viviendo.mysite.net/abcd/ws/residentservice.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Open in new window

0
Comment
Question by:javierpdx
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39726004
The error is fairly explanatory:  You are trying to assign the result of the function to a variable of the wrong type. The compiler is expecting to see this:

viviendo.ResidentService RS= new viviendo.ResidentService();
Viviendo.CustomerResult RSA = new Viviendo.CustomerResult();

try 
{
    RSA = RS.getCustomer("123456789");
}

Open in new window


If you mouse over the function within the IDE, VS will show you what the return type of the function is.
0
 

Author Closing Comment

by:javierpdx
ID: 39726622
Thank you!  I appreciate the help.
0
 

Author Comment

by:javierpdx
ID: 39727342
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now