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

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.

Related

Service Fabric Application doesn't register and run the Actor

I am developing APIs with Service Fabric into a big solution. After I created the services I needed (an Actor, a stateful and a stateless with .NET Framework) and I made a walking skeleton of the APIs.
I started to test and service fabric always threw the error "Service does not exist" (I'm 100% sure that the uri was right) when was the time to call the Actor (same error with both ActorProxyFactory and ActorProxy). I wathced on Cluster Explorer and under my SF App there was only the other two service. But the ActorServiceType was registered.
So I decide to create two simple SF app with an actor and I got the same error and also I don't see them on Cluster explorer.
In no projects I touched the ServiceManifest, ApplicationManifest or whatelse.
Here the versions of the tools I use:
Windows 11 Enterprise
Visual Studio Enterprise v16.11.9 with .Net Framework 4.7.1
Service Fabric Runtime 8.1.321.9590
Serive Fabric SDK 5.1.321.9590
Nuget Microsoft.SerivceFabric 8.1.321
Nuget Microsoft.ServiceFabric.Actors 5.1.321 (For the nuget packages I tried everything)
Microsoft.VisualStudio.Azure.Fabric.MSBuild 1.7.6 (also this I tried
every version)
My auto-generated setting.xml:
<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Section Name="MyActorServiceReplicatorConfig">
<Parameter Name="ReplicatorEndpoint" Value="MyActorServiceReplicatorEndpoint" />
<Parameter Name="BatchAcknowledgementInterval" Value="0.005" />
</Section>
<Section Name="MyActorServiceReplicatorSecurityConfig">
<Parameter Name="CredentialType" Value="None" />
</Section>
<!-- The content will be generated during build -->
</Settings>
My auto-generated service-manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="MyActorPkg" Version="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ServiceTypes>
<StatefulServiceType ServiceTypeName="MyActorServiceType" HasPersistedState="true">
<Extensions>
<Extension Name="__GeneratedServiceType__" GeneratedId="5f4d2e71-68d5-43f4-b8a3-60990017b54d|Persisted">
<GeneratedNames xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
<DefaultService Name="MyActorService" />
<ReplicatorEndpoint Name="MyActorServiceReplicatorEndpoint" />
<ReplicatorConfigSection Name="MyActorServiceReplicatorConfig" />
<ReplicatorSecurityConfigSection Name="MyActorServiceReplicatorSecurityConfig" />
<StoreConfigSection Name="MyActorServiceLocalStoreConfig" />
<ServiceEndpointV2_1 Name="MyActorServiceEndpointV2_1" />
</GeneratedNames>
</Extension>
</Extensions>
</StatefulServiceType>
</ServiceTypes>
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>MyActor.exe</Program>
</ExeHost>
</EntryPoint>
</CodePackage>
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="MyActorServiceEndpointV2_1" />
<Endpoint Name="MyActorServiceReplicatorEndpoint" />
</Endpoints>
</Resources>
<!-- The content will be generated during build -->
</ServiceManifest>
my auto-generated application-manifest:
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="MyActorPkg" Version="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ServiceTypes>
<StatefulServiceType ServiceTypeName="MyActorServiceType" HasPersistedState="true">
<Extensions>
<Extension Name="__GeneratedServiceType__" GeneratedId="5f4d2e71-68d5-43f4-b8a3-60990017b54d|Persisted">
<GeneratedNames xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
<DefaultService Name="MyActorService" />
<ReplicatorEndpoint Name="MyActorServiceReplicatorEndpoint" />
<ReplicatorConfigSection Name="MyActorServiceReplicatorConfig" />
<ReplicatorSecurityConfigSection Name="MyActorServiceReplicatorSecurityConfig" />
<StoreConfigSection Name="MyActorServiceLocalStoreConfig" />
<ServiceEndpointV2_1 Name="MyActorServiceEndpointV2_1" />
</GeneratedNames>
</Extension>
</Extensions>
</StatefulServiceType>
</ServiceTypes>
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>MyActor.exe</Program>
</ExeHost>
</EntryPoint>
</CodePackage>
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="MyActorServiceEndpointV2_1" />
<Endpoint Name="MyActorServiceReplicatorEndpoint" />
</Endpoints>
</Resources>
<!-- The content will be generated during build -->
</ServiceManifest>
my local1node.xml file:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/TEST2.MYACTOR.SF" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters />
</Application>
screens cluster explorer:
screen cluster explorer
screen cluster explorer service type
The solution of this problem found on this github issue with a step-by-step guide.
In few words if you have more than installation of Visual Studio (2019 and 2022) a service fabric package cache go in conflict.

keep getting ERR.SWS.CLIENT.VALIDATION_FAILED exception when calling PassengerDetailsRQ

I am using Sabre SOAP Api in C#. I got the response from session creation successfully, I added wsdl Service Reference
http://files.developer.sabre.com/wsdl/sabreXML1.0.00/ServicesPlatform/PassengerDetails3.3.0RQ.wsdl to my test project and pass required values to parameters in the request as given in the documentation https://developer.sabre.com/docs/read/soap_apis/management/itinerary/Passenger_Details.
this is my xml to that is send to sabre and Getting Exception
<?xml version="1.0" encoding="utf-16"?>
<PassengerDetailsRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.2.1"
IgnoreOnError="false">
<MiscSegmentSellRQ xmlns="http://services.sabre.com/sp/pd/v3_2">
<MiscSegment DepartureDateTime="2018-01-10T16:45" InsertAfter="0" NumberInParty="1" Status="HK" Type="OTH">
<OriginLocation LocationCode="SAN" />
<Text>America Tours</Text>
<VendorPrefs>
<Airline Code="DL" />
</VendorPrefs>
</MiscSegment>
</MiscSegmentSellRQ>
<PostProcessing xmlns="http://services.sabre.com/sp/pd/v3_2">
<EndTransactionRQ>
<EndTransaction Ind="true">
<Email Ind="true" />
</EndTransaction>
<Source ReceivedFrom="SWS TESTING" />
</EndTransactionRQ>
</PostProcessing>
<PreProcessing xmlns="http://services.sabre.com/sp/pd/v3_2" />
<PriceQuoteInfo xmlns="http://services.sabre.com/sp/pd/v3_2">
<Link NameNumber="1.1" Record="1" />
</PriceQuoteInfo>
<SpecialReqDetails xmlns="http://services.sabre.com/sp/pd/v3_2">
<SpecialServiceRQ>
<SpecialServiceInfo>
<SecureFlight>
<PersonName DateOfBirth="02/02/1998" NameNumber="1.1">
<GivenName>Usama QW</GivenName>
<Surname>Alam</Surname>
</PersonName>
<VendorPrefs>
<Airline />
</VendorPrefs>
</SecureFlight>
</SpecialServiceInfo>
</SpecialServiceRQ>
</SpecialReqDetails>
<TravelItineraryAddInfoRQ xmlns="http://services.sabre.com/sp/pd/v3_2">
<AgencyInfo>
<Address>
<AddressLine>America Tours</AddressLine>
<CityName>Los Angeles</CityName>
<CountryCode>US</CountryCode>
<PostalCode>90020</PostalCode>
<StateCountyProv StateCode="CA" />
<StreetNmbr>3434 West 6th Street Suite 400-6</StreetNmbr>
</Address>
<Ticketing TicketType="7T-A" />
</AgencyInfo>
<CustomerInfo>
<ContactNumbers>
<ContactNumber NameNumber="1.1" Phone="213-738-8185" PhoneUseType="A" />
<ContactNumber NameNumber="1.1" Phone="3162881034" PhoneUseType="A" />
</ContactNumbers>
<Email Address="www.usamaalam60#gmail.com" ShortText="AmericaTours" />
<Email Address="admin#koreaonly.com" ShortText="AmericaTours" />
<PersonName NameNumber="1.1" NameReference="MR" PassengerType="ADT">
<GivenName>Usama sd</GivenName>
<Surname>Alam</Surname>
</PersonName>
</CustomerInfo>
</TravelItineraryAddInfoRQ>
</PassengerDetailsRQ>
For this one you seem to be using invalid service version for the 3.2 namespace. Try with something like this:
*xmlns="http://services.sabre.com/sp/pd/v3_2"* and *version="3.2.0"*.
You were using version 2.2.1 here which will require a different URL.
Are you intending to use 3.2.0 version? I can see that the dates are not valid as per the schema as well. You have:
*DateOfBirth="02/02/1998"*
but should have:
*DateOfBirth="1998-02-02"*

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

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.

VS 2008 wsdl tool converting xsd:positiveInteger to string

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.

Categories