VS 2008 wsdl tool converting xsd:positiveInteger to string - c#

I have a web service written in C++ using gSoap. One of the methods of the webservice is
int HS__TBusinessComponentGetContents( xsd__positiveInteger pSession,
xsd__positiveInteger pComponentType,
xsd__string pPath,
xsd__string pFilter,
xsd__string pChangedAfter,
xsd__positiveInteger pFlags,
xsd__string &rResult);
Using these typedefs:
typedef double xsd__double;
typedef wchar_t *xsd__string;
typedef bool xsd__boolean;
typedef int xsd__int;
typedef unsigned long long xsd__positiveInteger;
typedef wchar_t *xsd__datetime;
I generate a wsdl file using this definition which has this (correct) part:
However, when I generate a Proxy class using the Visual Studio 2008 wsdl.exe tool to create a class which I can use from C#, the definition of the above methods is as follows:
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="urn:tango04-hydra-server", ResponseNamespace="urn:tango04-hydra-server")]
[return: System.Xml.Serialization.SoapElementAttribute("rResult")]
public string TBusinessComponentGetContents([System.Xml.Serialization.SoapElementAttribute(DataType="positiveInteger")] string pSession, [System.Xml.Serialization.SoapElementAttribute(DataType="positiveInteger")] string pComponentType, string pPath, string pFilter, string pChangedAfter, [System.Xml.Serialization.SoapElementAttribute(DataType="positiveInteger")] string pFlags) {
object[] results = this.Invoke("TBusinessComponentGetContents", new object[] {
pSession,
pComponentType,
pPath,
pFilter,
pChangedAfter,
pFlags});
return ((string)(results[0]));
}
The WSDL is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Publisher"
targetNamespace="http://127.0.0.1:18084/Publisher.wsdl"
xmlns:tns="http://127.0.0.1:18084/Publisher.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:HS="urn:tango04-hydra-server"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="urn:tango04-hydra-server"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:HS="urn:tango04-hydra-server"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
</schema>
</types>
<message name="SessionOpenRequest">
<part name="vCredentials" type="xsd:string"/>
</message>
<message name="SessionOpenResponse">
<part name="rResult" type="xsd:positiveInteger"/>
</message>
<message name="SessionCloseRequest">
<part name="rSession" type="xsd:positiveInteger"/>
</message>
<message name="SessionCloseResponse">
<part name="rResult" type="xsd:boolean"/>
</message>
<message name="SoapTestRequest">
</message>
<message name="SoapTestResponse">
<part name="rResult" type="xsd:boolean"/>
</message>
<message name="TBusinessComponentGetContentsRequest">
<part name="pSession" type="xsd:positiveInteger"/>
<part name="pComponentType" type="xsd:positiveInteger"/>
<part name="pPath" type="xsd:string"/>
<part name="pFilter" type="xsd:string"/>
<part name="pChangedAfter" type="xsd:string"/>
<part name="pFlags" type="xsd:positiveInteger"/>
</message>
<message name="TBusinessComponentGetContentsResponse">
<part name="rResult" type="xsd:string"/>
</message>
<portType name="PublisherPortType">
<operation name="SessionOpen">
<documentation>Service definition of function HS__SessionOpen</documentation>
<input message="tns:SessionOpenRequest"/>
<output message="tns:SessionOpenResponse"/>
</operation>
<operation name="SessionClose">
<documentation>Service definition of function HS__SessionClose</documentation>
<input message="tns:SessionCloseRequest"/>
<output message="tns:SessionCloseResponse"/>
</operation>
<operation name="SoapTest">
<documentation>Service definition of function HS__SoapTest</documentation>
<input message="tns:SoapTestRequest"/>
<output message="tns:SoapTestResponse"/>
</operation>
<operation name="TBusinessComponentGetContents">
<documentation>Service definition of function HS__TBusinessComponentGetContents</documentation>
<input message="tns:TBusinessComponentGetContentsRequest"/>
<output message="tns:TBusinessComponentGetContentsResponse"/>
</operation>
</portType>
<binding name="Publisher" type="tns:PublisherPortType">
<SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SessionOpen">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="SessionClose">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="SoapTest">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="TBusinessComponentGetContents">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:tango04-hydra-server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="Publisher">
<documentation>Tango/04 Computing Group - Publisher </documentation>
<port name="Publisher" binding="tns:Publisher">
<SOAP:address location="http://127.0.0.1:18084"/>
</port>
</service>
</definitions>
My question is: why is this happening? Shouldn't the parameters be integers, or long long values instead of strings for the parameters that in the wsdl are marked as xsd:positiveInteger? What am I doing wrong here?
Thanks!

This may not be what you want to see but this may help: Microsoft
Basically what it gives you are the .Net datatypes that are associated with each xsd datatype. On that page it shows positiveInteger as a string. So, long story short it's doing what it's supposed to do. If you really want a number data type you may want to maybe look into using a Unsigned data type instead of positive integer, if you need it to always be positive. Otherwise just use an appropriate xsd datatype that will work for you. Since it looks like you have control over the web service and wsdl in c++ this should not be too difficult. If this is not something you want to do you will probably need to add logic checks on your c# client to make sure you are sending a number. Since everything technically goes over the wire as an xml string it technically doesn't matter as long as the service can serialize your request properly. Thus having data checks on your consumer object.
On a side note, when I have needed to develop services in the past we have always handcoded the xsd / wsdl contracts instead of letting tools generate them so we always know exactly what we will get. Not sure if that is what you have done but you could do that as well. When we do this we use the wsdl tool to generate the server proxy and the client proxy so you could generate the server side in cpp and the client in cs and then just fill in the guts the way you need it.
Hopefully that helps you out.

Related

Creating a consumer of a Web Service WSDL/SOAP

I am attempting to write a Windows Desktop App (using WCF) that is a consumer of a web service.
The application:
Sends a SOAP message to a British Government Server to get an authentication token based on the arugments passed
Retrieves a response from that server in the form of a string which contains the authentication token.
I have a template of the SOAP message from the British Government, and a WSDL file for the service.
What I have tried
Add a service reference using the WSDL file. I received the following error: URI formats are not supported.
Add a Web Reference using the URL of the service. I received the following error: The request failed with HTTP status 405: Method Not Allowed.
Send the SOAP request using a POST. The Call to GetResponse() threw a 500 External Server Error.
NOTE: I am using VS 2005
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s1="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication">
<types>
<s:schema elementFormDefault="qualified" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns="https://tpvs.hmrc.gov.uk/dpsauthentication">
<s:element name="DPSrequestToken">
<s:complexType>
<s:sequence>
<s:element name="version" type="s:int"/>
<s:element name="vendorID" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DPSrequestTokenResponse">
<s:complexType>
<s:sequence>
<s:element name="DPSrequestTokenResult" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="DPSrequestTokenSoapIn">
<part name="parameters" element="s1:DPSrequestToken"/>
</message>
<message name="DPSrequestTokenSoapOut">
<part name="parameters" element="s1:DPSrequestTokenResponse"/>
</message>
<portType name="dpsauthenticationSoap">
<operation name="DPSrequestToken">
<input message="s1:DPSrequestTokenSoapIn"/>
<output message="s1:DPSrequestTokenSoapOut"/>
</operation>
</portType>
<binding name="dpsauthenticationSoap" type="s1:dpsauthenticationSoap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="DPSrequestToken">
<soap:operation soapAction="https://tpvs.hmrc.gov.uk/dpsauthentication/DPSrequestToken" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="dpsauthentication">
<port name="dpsauthenticationSoap" binding="s1:dpsauthenticationSoap">
<soap:address location="https://dps.ws.hmrc.gov.uk/dpsauthentication/service"/>
</port>
</service>
</definitions>
SOAP:
<!-- v1.1 30/11/2007 -->
<!-- 24/10/2011 - minor change to remove duplicated text from <Envelope> element. No impact on validation, therefore not re-versioned. -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>as advised by SDS team</wsse:Username>
<wsse:Password>as advised by SDS team</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:DPSrequestToken xmlns:m="https://tpvs.hmrc.gov.uk/dpsauthentication">
<m:version>1</m:version>
<m:vendorID>your 4 digit vendorID</m:vendorID>
</m:DPSrequestToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In case someone else runs across the same issue, I was able to solve this issue by using the WSDL.exe program that is normally found in 2. C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\.
This program creates a proxy class for a web service that allows you to call the API's methods localy in your code.
In command line WSDL.exe is called like this: 3.
wsdl http://host/web_service/web_service.asmx?WSDL

Importing WSDL into a .NET project only creates an empty namespace

I'm trying to use WCF for the first time. Here's what I did:
Created a console .NET 4 project in VS 2010
Added a WSDL file as a service reference.
However, I can't seem to be able to use the service, because no classes were created. The service reference is just an empty namespace.
What am I missing?
Here is the WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Christophe Duquesne (DRYADE SA) -->
<!-- edited with XMLSpy v2007 rel. 3 U (http://www.altova.com) by Nick js Knowles (Kizoom) -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:siriWS="http://new.webservice.namespace" xmlns:siri="http://www.siri.org.uk/siri" xmlns:ns="http://datex2.eu/schema/1_0/1_0" xmlns:ns1="http://www.ifopt.org.uk/acsb" xmlns:ns2="http://www.ifopt.org.uk/ifopt" targetNamespace="http://new.webservice.namespace">
<types>
<xsd:schema targetNamespace="http://new.webservice.namespace">
<xsd:import schemaLocation="siri.xsd" namespace="http://www.siri.org.uk/siri"/>
</xsd:schema>
</types>
<message name="StopMonitoringServiceRequest">
<part name="Request" type="siri:ServiceRequestStructure"/>
</message>
<message name="StopMonitoringServiceDelivery">
<part name="Answer" type="siri:ServiceDeliveryStructure"/>
</message>
<portType name="SOAP-Port">
<operation name="GetStopMonitoringService">
<input message="siriWS:StopMonitoringServiceRequest"/>
<output message="siriWS:StopMonitoringServiceDelivery"/>
</operation>
</portType>
<binding name="SiriSOAPBinding" type="siriWS:SOAP-Port">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<!-- ====general services ===== -->
<!-- ====SIRI services ===== -->
<operation name="GetStopMonitoringService">
<soap:operation soapAction="GetStopMonitoringService"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="SiriServices">
<port name="SiriWSPort" binding="siriWS:SiriSOAPBinding">
<soap:address location="http://www.siri-service-location.com"/>
</port>
</service>
<!--General messages-->
<!--SIRI Functional services-->
<!--Capabilities-->
<xsd:annotation>
<xsd:appinfo xmlns:gms="http://www.govtalk.gov.uk/CM/gms">
<Metadata xmlns="http://www.govtalk.gov.uk/CM/gms-xs">
<Aggregation>main schema</Aggregation>
<Audience>e-service developers</Audience>
<Contributor>Nicholas Knowles, KIZOOM LTD., London EC4A 1LT</Contributor>
<Coverage>Europe</Coverage>
<Creator>>Drafted for version 1.0, by Cen TC278 WG3 SG7 Christophe Duquesne DRYADE SA mailto:schemer#siri.org.uk</Creator>
<Date>
<Created>2005-03-01</Created>
</Date>
<Date>
<Modified>2005-05-11</Modified>
</Date>
<Date>
<Modified>2007-01-30</Modified>
</Date>
<Date>
<Modified>2007-04-17</Modified>
<!-- Name Space changes -->
</Date>
<Date>
<Modified>2008-02-12</Modified>
<!-- Situation Exchnages -->
</Date>
<Date>
<Modified>2007-04-17</Modified>
<!-- Name Space correction -->
<!-- Add StopMonitoringMultipleRequest -->
</Date>
<Description>
<p>SIRI is a European CEN standard for the exchange of real time information. This describes WSDL Server binding</p>
</Description>
<Format>
<MediaType>text/xml</MediaType>
<Syntax>http://www.w3.org/2001/XMLSchema</Syntax>
<Description>XML schema, W3C Recommendation 2001</Description>
</Format>
<Identifier>{http://www.siri.org.uk/schemas/1.3/siri}siri_wsProducer.wsdl</Identifier>
<Language>[ISO 639-2/B] ENG</Language>
<Publisher>Kizoom, 109-123 Clifton Street, London EC4A 4LD </Publisher>
<Rights>Unclassified
<Copyright>CEN, VDV, RTIG 2005-2008</Copyright>
</Rights>
<Source>
<ul>
<li>SIRI is derived from the VDV, RTIGXML and Trident standards.</li>
</ul>
</Source>
<Status>Version 1.0 Draft for approval</Status>
<Subject>
<Category>Arts, recreation and travel, Tourism, Travel (tourism), Transport,
Air transport, Airports,
Ports and maritime transport, Ferries (marine),
Public transport, Bus services, Coach services, Bus stops and stations,
Rail transport, Railway stations and track, Train services, Underground trains,
Business and industry, Transport, Air transport , Ports and maritime transport, Public transport,
Rail transport, Roads and road transport
</Category>
<Project>Cen TC278 WG3 SG7</Project>
</Subject>
<Title>SIRI XML schema. WSDL Server binding. </Title>
<Type>Standard</Type>
</Metadata>
</xsd:appinfo>
</xsd:annotation>
<!-- ======== All the structures are comming from siri.xsd ========= -->
<!-- ======== Descritions of request parameters (requests and answers) ========= -->
<!-- ========Service Requests ========= -->
<!-- ====StopMonitoring== -->
<!-- ====PORTS ================ -->
<!-- ====BINDINGS ================ -->
</definitions>
Apparently there were errors importing the schemas, I should have looked in the Error List window.
Try run the command tool wsdl.exe instead. I tried it with your wsdl and there were some errors. Save the wsdl to a file(here service.wsdl) and try to run:
wsdl service.wsdl /language:CS
A file called something like Service.cs should be created that you can include in your project.

400 Bad Request Exception: Simple SOAP WCF service with small data

I have a simple WCF service suing SOAP. I have a very simple operation “GetMultiplied “ with very small amount of data. I am getting following exception when client try to call the operation. Any idea what all could be the issues?
Inner Exception: {"The remote server returned an error: (400) Bad Request."}
Complete wsdl and schema is listed at the end.
Note: I have set quota values, maxBufferSize etc to higher values in both service and client config.
Tracing in Service
When I used tracing in service (based on How to turn on WCF tracing?), I am getting the following - seems like there is no error logged.
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2012-09-13T17:05:17.6059181Z" />
<Source Name="System.ServiceModel" />
<Description>AppDomain unloading.</Description>
Service implementation
public class CalculationService : ICalculationService
{
public virtual GetMultipliedResponse GetMultiplied(GetMultipliedRequest request)
{
MultipliedResult result = new MultipliedResult();
result.ResultNumber= ((request.InputNumber)*2);
GetMultipliedResponse response = new GetMultipliedResponse(result);
return response;
}
}
Client
static void Main(string[] args)
{
CalculationServiceInterfaceClient proxy = new CalculationServiceInterfaceClient();
multipliedResult result = proxy.getMultiplied(2);
}
In the auto generated code the detail is:
public NewClient.CalcReference.multipliedResult getMultiplied(int inputNumber)
{
NewClient.CalcReference.getMultipliedRequest inValue = new NewClient.CalcReference.getMultipliedRequest();
inValue.inputNumber = inputNumber;
NewClient.CalcReference.getMultipliedResponse retVal = ((NewClient.CalcReference.CalculationServiceInterface)(this)).getMultiplied(inValue);
return retVal.restaurants;
}
WSDL
<definitions xmlns:import0="urn:lijo:demos:multiplyservice:messages:v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:import1="urn:lijo:demos:multiplyservice:data:v1" xmlns:tns="urn:lijo:demos:multiplyservice:calculation:v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CalculationService" targetNamespace="urn:lijo:demos:multiplyservice:calculation:v1" xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<types>
<xsd:schema>
<xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantMessages.xsd" namespace="urn:lijo:demos:multiplyservice:messages:v1" />
<xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantData.xsd" namespace="urn:lijo:demos:multiplyservice:data:v1" />
</xsd:schema>
</types>
<message name="getMultipliedIn">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultiplied" />
</message>
<message name="getMultipliedOut">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultipliedResponse" />
</message>
<portType name="CalculationServiceInterface">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<operation name="getMultiplied">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<input message="tns:getMultipliedIn" />
<output message="tns:getMultipliedOut" />
</operation>
</portType>
<binding name="BasicHttpBinding_CalculationServiceInterface" type="tns:CalculationServiceInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getMultiplied">
<soap:operation soapAction="urn:lijo:demos:multiplyservice:calculation:v1:getMultipliedIn" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="CalculationServicePort">
<port name="CalculationServicePort" binding="tns:BasicHttpBinding_CalculationServiceInterface">
<soap:address location="http://localhost/CalculationService" />
</port>
</service>
</definitions>
XSD
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="RestaurantData" targetNamespace="urn:lijo:demos:multiplyservice:data:v1"
elementFormDefault="qualified" xmlns="urn:lijo:demos:multiplyservice:data:v1"
xmlns:mstns="urn:lijo:demos:multiplyservice:data:v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="multipliedResult">
<xs:sequence>
<xs:element name="resultNumber" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Cleint Config (Autogenerated)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_CalculationServiceInterface"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="524288" maxStringContentLength="524288" maxArrayLength="524288"
maxBytesPerRead="524288" maxNameTableCharCount="524288" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/CalculationService" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_CalculationServiceInterface"
contract="CalcReference.CalculationServiceInterface" name="CalculationServicePort" />
</client>
</system.serviceModel>
I solved the problem :-)
I will publish the answer for the benefit of others.
Key problem: I was trying to use the manually created wsdl. (I reffered the local copy available inside service - I was using a tool to generate the service code from wsdl). The service was not providing it. I should have tried to view the wsdl from browsing the svc file
Ran the service using WcfTestClient. Gave an error that revealed the project name and the namespace that we use should be same. (Otherwise it will append the project name before the namespace name and that will become incorrect namespace)
Type the “WcfTestClient” command in “Visual Studio Command Prompt”. http://blogs.msdn.com/b/wcftoolsteamblog/archive/2010/01/04/tips-for-launching-wcf-test-client.aspx
By browsing the svc file in the service, it showed that the metadata publishing is not enabled. Added a service behavior for meta data browsing in the web.config.
Used relative path for the service (instead of localhost) error "No protocol binding matches the given address ..."
Service Tracing also can be helpful (though did not help me here). Used "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\SvcTraceViewer.exe". Followed the post and the Error file (initializeData="Error.svclog") is stored inside the solution project. Changing it to other locations did not work. How to turn on WCF tracing?
Refer One WCF service – two clients; One client does not work

How can we know the input/output type of wcf service?

I am new to WCF and I wrote some service in wcf. It is now published on the Intranet and some applications are already using that service. At the moment, I have to make the documentation about the input parameters / data type and output parameters for other developers. It is ok, if we use .Net platform to consume the service. It automatically creates the services/classes in the WebReferences folder and Intellisense work perfectly.
But if the user is using PHP or classic ASP, it doesn't work that way. They have to know exact name, type of the parameters and I have to document the services very carefully.
By using WSDL as below: how can we know the datatype and parameters of the service we want to use? If it doesn't show in WSDL, where should I look at these information? If someone gave me WCF service without documentation, how could I know how to use that service?
Thanks very much.
This following is my Interface about the Service
[ServiceContract]
public interface IEmail
{
[OperationContract]
bool InsertEmail(string Subject, string SentFrom, string SentTo, int ApplicationID, int TemplateID, string DataText);
}
The following is the exact WSDL info about my service.
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions name="Email" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
- <wsdl:message name="IEmail_InsertEmail_InputMessage">
<wsdl:part name="parameters" element="tns:InsertEmail" />
</wsdl:message>
- <wsdl:message name="IEmail_InsertEmail_OutputMessage">
<wsdl:part name="parameters" element="tns:InsertEmailResponse" />
</wsdl:message>
- <wsdl:portType name="IEmail">
- <wsdl:operation name="InsertEmail">
<wsdl:input wsaw:Action="http://tempuri.org/IEmail/InsertEmail" message="tns:IEmail_InsertEmail_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IEmail/InsertEmailResponse" message="tns:IEmail_InsertEmail_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_IEmail" type="tns:IEmail">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="InsertEmail">
<soap:operation soapAction="http://tempuri.org/IEmail/InsertEmail" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Email">
- <wsdl:port name="BasicHttpBinding_IEmail" binding="tns:BasicHttpBinding_IEmail">
<soap:address location="http://myservice/Email.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
If you mean that you can't see all the types your service uses in the WSDL, this is because the WSDL WCF creates is often (maybe always) split into several bits. These other bits are linked to from the main WSDL.
So if you browse to http://myservice/Email.svc?wsdl, you'll see the WSDL you've put in your question. In here, you can see links to two other schemas - http://myservice/Email.svc?xsd=xsd0 and http://myservice/Email.svc?xsd=xsd1. If you browse to these, you'll find the type information you're looking for.

Calling PHP webservice from .Net

I have created a Webservice in PHP and I'm trying to call it from my C# code.
When I try to create a proxy using wsdl utility
wsdl http://localhost:5365/DemoService.php?wsdl
I get this errors
Error: Cannot find definition for http://myserver.co.za/sayHello:sayHelloPortType.
Service Description with namespace http://myserver.co.za/sayHello is missing.
Parameter name: name
Here's my Webservice code (DemoService.php)
<?php
function sayHello($name){
$salutation = "Hi $name !";
return $salutation;
}
$server = new SoapServer("greetings.wsdl");
$server->addFunction("sayHello");
$server->handle();
?>
and my WSDL code (greetings.wsdl)
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='greetings'
targetNamespace='http://myserver.co.za/sayHello'
xmlns:tns=' http://myserver.co.za/sayHello'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='sayHelloRequest'>
<part name='name' type='xsd:string'/>
</message>
<message name='sayHelloResponse'>
<part name='salutation' type='xsd:string'/>
</message>
<portType name='sayHelloPortType'>
<operation name='sayHello'>
<input message='tns:sayHelloRequest'/>
<output message='tns:sayHelloResponse'/>
</operation>
</portType>
<binding name='sayHelloBinding' type='tns:sayHelloPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='sayHello'>
<soap:operation soapAction=''/>
<input>
<soap:body use='encoded' namespace=''
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace=''
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<documentation>This is Wiley's SOAP server Example</documentation>
<service name='sayHelloService'>
<port name='sayHelloPort' binding='sayHelloBinding'>
<soap:address location='http://localhost:5365/DemoService.php'/>
</port>
</service>
</definitions>
I really don't understand what it is trying to say. Can some one point me in a right direction?
Here is what is wrong with the WSDL
First the xmlns:tns namespace has a space at the start of it
xmlns:tns=' http://myserver.co.za/sayHello' <-- Bad
xmlns:tns='http://myserver.co.za/sayHello' <-- Good
Next the <documentation> node is in the wrong place, it should be inside the <service> node like so
<service ...>
<documentation>This is Wiley's SOAP server Example</documentation>
<port ...>
...
</port>
</service>
Your port binding element needs to use the tns namespace
<port name='sayHelloPort' binding='sayHelloBinding'> <-- Bad
<port name='sayHelloPort' binding='tns:sayHelloBinding'> <-- Good
Finally I could not get the soap:body to import as encoded, and had to swap them to literal, also note they need a value in the namespace element
<soap:body use='literal' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
I believe the soapAction element in the <soap:operation soapAction=''/> node still needs a value to work correctly, something like urn:xmethods-delayed-quotes#sayHello, but it will import without it.
Full WSDL (I caan import this using WSDL.exe without error)
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='greetings'
targetNamespace='http://myserver.co.za/sayHello'
xmlns:tns='http://myserver.co.za/sayHello'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='sayHelloRequest'>
<part name='name1' type='xsd:string'/>
</message>
<message name='sayHelloResponse'>
<part name='salutation' type='xsd:string'/>
</message>
<portType name='sayHelloPortType'>
<operation name='sayHello'>
<input message='tns:sayHelloRequest'/>
<output message='tns:sayHelloResponse'/>
</operation>
</portType>
<binding name='sayHelloBinding' type='tns:sayHelloPortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='sayHello'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='literal' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='sayHelloService'>
<documentation>Service Description</documentation>
<port name='sayHelloPort' binding='tns:sayHelloBinding'>
<soap:address location='http://localhost:5365/DemoService.php'/>
</port>
</service>
</definitions>
Why don't you add the reference to the web service through:
right-click on project file -> add web reference --> type in the url to the webservice and voila!
This should create the necessary entries in Web.config (or App.config) plus the proxy classes that you'll use in your app.

Categories