Can somebody help me access this web service? How am i going to call this service on my code? Will this work?
MyService.InputParameters input = new MyService.InputParameters();
input.attribute = " blah blah";
MyService.OutputParameteers = execute(input);
Thanks you !!!!
<wsdl:message name="requestMessage">
<wsdl:part name="request" element="inp1:InputParameters"/>
</wsdl:message>
<wsdl:message name="replyMessage">
<wsdl:part name="reply" element="inp1:OutputParameters"/>
</wsdl:message>
<wsdl:portType name="execute_ptt">
<wsdl:operation name="execute">
<wsdl:input message="tns:requestMessage"/>
<wsdl:output message="tns:replyMessage"/>
</wsdl:operation>
</wsdl:portType>
James,
I think this is what you are looking for.
http://code.msdn.microsoft.com/How-to-call-External-WCF-42c4490d
Hope this helps !!!
Related
I'm making a NodeJS web service that contains API REST and SOAP methods (Im using https://www.npmjs.com/package/soap) with Express. With API REST I don't have any problem but with SOAP I have an inconvenient, when I try to consume the SOAP method from a testing C# application I can see that the parameters are going fine, but in the response I have the next error in C# (Response is not correct XML code)
When I consume the method from a NodeJS client with node-soap too the response working fine.
Part of my NodeJS code:
const express = require('express');
const bodyParser = require('body-parser');
const soap = require('soap');
const fs = require('fs');
const xml = fs.readFileSync('src/templates/ws_soap.wsdl', 'utf8');
const app = express();
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
const soap_service = {
integrations: {
pull: {
getSnapshotGIGA: function(args) {
return {
res: "HOLA"
};
},
}
}
};
app.listen(port, ip, function() {
soap.listen(app, '/integrations_service', soap_service, xml, function() {
console.log('SOAP web service started on ' + ip + ':' + port);
});
console.log('API REST started on ' + ip + ':' + port);
});
My WSDL file is next (In response I have the type string because I wanted to see how it behaved, but I need to return an object XML):
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="integrations_service" targetNamespace="http://localhost:4205/integrations_service" xmlns="http://localhost:4205/integrations_service" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="getSnapshotGIGARequest">
<wsdl:part name="User" type="xs:string"/>
<wsdl:part name="Password" type="xs:string"/>
</wsdl:message>
<wsdl:message name="getSnapshotGIGAResponse">
<wsdl:part name="res" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="pull_integrations">
<wsdl:operation name="getSnapshotGIGA">
<wsdl:input message="getSnapshotGIGARequest"/>
<wsdl:output message="getSnapshotGIGAResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="pull_integrations_binding" type="pull_integrations">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getSnapshotGIGA">
<soap:operation soapAction="getSnapshotGIGA"/>
<wsdl:input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="integrations">
<wsdl:port binding="pull_integrations_binding" name="pull">
<soap:address location="http://localhost:4205/integrations_service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In C# I have an console application and I have registered the SOAP service as a web referency.
The way I consume the SOAP method is (When I make a SOAP Service with C# I test methods from this way too because is the way clients working):
Console.WriteLine("Consume NodeJS SOAP service");
Thread.Sleep(500);
integrations_service.integrations integrations = new integrations_service.integrations();
integrations.Url = "http://localhost:4205/integrations_service?wsdl";
var some_response = integrations.getSnapshotGIGA("myuser", "123456");
Console.WriteLine("Press enter to out...");
I want to get the response in and XmlNode like in this example:
Console.WriteLine("Consume C# SOAP service");
Thread.Sleep(500);
serviceSOAP sSOAP = new serviceSOAP ();
sSOAP.Url = "http://my.domain.com.mx/";
XmlNode xmlNode = sSOAP .anyMethodSoap("yomero", "123456");
Console.WriteLine(XElement.Parse(xmlNode.OuterXml).ToString());
Thread.Sleep(500);
If you know how I can return the XML from NodeJS and get it correctly in C# or any idea, I would appreciate it. Reggards.
Answer to my question, the problem was the WSDL configuration. With this configuration I made this works with C# web reference. The principal problem, the style, I changed it from "rpc" to "document" and configure correctly the element for the response.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
name="devices_service"
targetNamespace="http://localhost:4205/devices_service"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:s="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://localhost:4205/devices_service">
<wsdl:types>
<xs:schema targetNamespace="http://localhost:4205/devices_service" xmlns="http://localhost:4205/devices_service" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="GetDevicesRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="User" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="Password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetDevicesResponse">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="GetDevicesSoapIn">
<wsdl:part name="parameters" element="GetDevicesRequest"/>
</wsdl:message>
<wsdl:message name="GetDevicesSoapOut">
<wsdl:part name="parameters" element="GetDevicesResponse"/>
</wsdl:message>
<wsdl:portType name="user_devices">
<wsdl:operation name="GetDevices">
<wsdl:input message="GetDevicesSoapIn"/>
<wsdl:output message="GetDevicesSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="user_devices_binding" type="user_devices">
<s:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<wsdl:operation name="GetDevices">
<s:operation soapAction="http://localhost:4205/devices_services/GetDevices"/>
<wsdl:input>
<s:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<s:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="devices">
<wsdl:port binding="user_devices_binding" name="user">
<s:address location="http://localhost:4205/devices_service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>**
You'll probably want to use one of:
node-soap
strong-soap (rewrite of node-soap)
easysoap
I am creating a WCF Client in VS 2013 using a supplied third party WSDL for a web service - most likely running on Java.
Running svcutil on the raw WSDL gives me an error similar to this:
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType:
//wsdl:definitions[#targetNamespace='<ns>']/wsdl:portType[#name='xxxPort']
XPath to Error Source:
//wsdl:definitions[#targetNamespace='<ns>']/wsdl:binding[#name='xxxPortSoap11']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding:
//wsdl:definitions[#targetNamespace='<ns>']/wsdl:binding[#name='xxxPortSoap11']
XPath to Error Source:
//wsdl:definitions[#targetNamespace='<ns>']/wsdl:service[#name='xxxPortService']/wsdl:port[#name='xxxPortSoap11']
Generating files...
Warning: No code was generated. ...
In order to get the Service Reference working (or svcutil running without errors) I have to comment out the fault definitions in the port and bindings. I can live with that (as I have made a MessageInspector to pull out errors from the various detail elements), but want to get it working properly.
Simplifying the WSDL to only show the elements that give me problems gives:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:tns="http://www.example.com/data/common/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:sch0="http://www.example.com/data/common/"
targetNamespace="http://www.example.com/data/common/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="http://www.example.com/data/common/"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="www.example.com/data/common/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType xmlns="http://www.w3.org/2001/XMLSchema" name="BusinessErrorType">
<xsd:sequence xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:element xmlns="http://www.w3.org/2001/XMLSchema"
name="Error" maxOccurs="unbounded" type="string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element xmlns="http://www.w3.org/2001/XMLSchema"
name="BusinessErrorFault" type="tns1:BusinessErrorType" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="BusinessErrorFault">
<wsdl:part name="BusinessErrorFault" element="sch0:BusinessErrorFault" />
</wsdl:message>
<wsdl:portType name="ViewMessagesPort">
<wsdl:operation name="BusinessError">
<wsdl:fault name="BusinessErrorFault" message="sch0:BusinessErrorFault" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ViewMessagesPortSoap11" type="sch0:ViewMessagesPort">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="BusinessError">
<soap:operation soapAction="" />
<wsdl:fault name="BusinessErrorFault">
<soap:fault use="literal" name="BusinessErrorFault" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ViewMessagesPortService">
<wsdl:port name="ViewMessagesPortSoap11" binding="sch0:ViewMessagesPortSoap11">
<soap:address location="https://www.example.com/ws/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have looked at many SO questions and other places on the net including Scott Hanselman's breaking the rules with no joy.
Hopefully it is something blindingly obvious ... I gratefully await any answers from across the pond as I wend my way home in the UK.
UPDATE
Passing the above WSDL through https://www.wsdl-analyzer.com/ gives an error on the binding:
Style: Unknown [Warn!]
Could not detect the 'use' for the operations of binding ViewMessagesPortSoap11
I'm still none the wiser.
The WSDL you published above has an issue that there is no schema with targetNamespace of "http://www.example.com/data/common/" which is what expected by the sch0:BusinessErrorFault element. I assume this may be because you did not provide the full WSDL so I changed the targetNamespace of the schema to it. The next error if this this operation:
<wsdl:operation name="BusinessError">
<wsdl:fault name="BusinessErrorFault" message="sch0:BusinessErrorFault" />
</wsdl:operation>
has no input or output but just fault, which does not make since.
I guess this might also be because you simplified the WSDL so please publish the full one if you get more errors.
I have a Java project ( a voting system ) in which I implemented a web service.
My getResults method returns a String[]. If the voting is done the method returns the array populated with 'Item 1 - 2 votes, Item 2 - 3 Votes...'. If it isn't, it returns the array with a single string saying that voting is still on.
The problem is that if i call getResults from within my java application it works as expected but if i call it from my webservice it always returns that the voting is still on and never the results.
I'm consuming this web service through a c# console application is visual studio.
I'm pretty new to web services so let me ask this. When I instantiate my service like this:
ServerService ss = new ServerService();
Does it create a new instance of my class Server() in my Java application or is it just a way to connect to my current instance?
Well I hope I've explained my problem well and hope you can help me.
Thanks and merry xmas :)
Edit:
this is the method that is accessed by the web service
public String[] getResults() throws RemoteException {
if (ended) {
return results.toArray(new String[results.size()]);
} else {
ArrayList<String> temp = new ArrayList<String>();
temp.add("Voting is still on");
return temp.toArray(new String[temp.size()]);
}
}
Edit 2:
WSDL:
<wsdl:definitions targetNamespace="http://backend.ve"
xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://backend.ve" xmlns:intf="http://backend.ve" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://backend.ve" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getResults">
<complexType/>
</element>
<element name="getResultsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="getResultsReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="getResultsRequest">
<wsdl:part element="impl:getResults" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getResultsResponse">
<wsdl:part element="impl:getResultsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="Server">
<wsdl:operation name="getResults">
<wsdl:input message="impl:getResultsRequest" name="getResultsRequest">
</wsdl:input>
<wsdl:output message="impl:getResultsResponse" name="getResultsResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServerSoapBinding" type="impl:Server">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getResults">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getResultsRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getResultsResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServerService">
<wsdl:port binding="impl:ServerSoapBinding" name="Server">
<wsdlsoap:address location="http://localhost:8080/VE/services/Server"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
C#:
namespace WSTest
{
class Program
{
static void Main(string[] args)
{
ServerService ss = new ServerService();
foreach (String s in ss.getResults())
{
Console.WriteLine(s);
}
Console.ReadLine();
}
}
}
It does only instantiate a C# proxy for your service - an automatically generated class by .NET with all the behind-the-scenes code to manage communication with your service.
I would advice you to test your service with a tool like SoapUI before trying to integrate it with .NET and see if you have the same problem.
I am not able to figure out the exact issue in your code, but here are some pointers which will help you to sort it out.
Your method is not returning the string, see WSDL:
<wsdl:operation name="getResults">
<wsdl:input message="impl:getResultsRequest" name="getResultsRequest">
</wsdl:input>
<wsdl:output message="impl:getResultsResponse" name="getResultsResponse">
</wsdl:output>
</wsdl:operation>
But you are expecting string as output in your C# code.
2 . You need to create two objects at C# end namely : getResultsRequest and getResultsResponse
I know you are getting same error through Eclipse, but since your service works fine when you call it from Java client. So your service logic is correct. Now only place where problem might occur is the communication between your service and client.
So my suggested C# code would be:
namespace WSTest
{
class Program
{
static void Main(string[] args)
{
ServerService ss = new ServerService();
getResultRequest request = new getResultRequest();
getResultResponse response = new getResultResponse();
response = ss.getResultResponse(request);
// Do something with response.
Console.ReadLine();
}
}
}
I have made a simple web service
wsdl:
<wsdl:definitions name='mysum' >
<wsdl:types>
<xsd:schema
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.my-uni-project.info/joomla/components/com_jv_vm_soa/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="mysum"
targetNamespace="http://www.my-uni-project.info/joomla/components/com_jv_vm_soa/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<xsd:complexType name="mysumRequest">
<xsd:all>
<xsd:element minOccurs="0" name="n1" type="xsd:int"/>
<xsd:element minOccurs="0" name="n2" type="xsd:int"/>
</xsd:all>
</xsd:complexType>
<xsd:element name="mysumResponse" type="xsd:int"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="mysumRequest">
<wsdl:part name="parameters" element="tns:mysumRequest" />
</wsdl:message>
<wsdl:message name="mysumResponse">
<wsdl:part name="result" element="tns:mysumResponse" />
</wsdl:message>
<wsdl:portType name="mysum">
<wsdl:operation name="mysum">
<wsdl:input message="tns:mysumRequest"/>
<wsdl:output message="tns:mysumResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="mysumSOAP" type="tns:mysum">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="mysum">
<soap:operation soapAction="mysum" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="mysum">
<wsdl:port name="mysumSOAP" binding="tns:mysumSOAP">
<soap:address location="http://www.my-uni-
project.info/joomla/components/com_jv_vm_soa/mysum.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
the service:
function mysum($parameters) {
$result = $parameters->item[0]->value + $parameters->item[1]->value;
return $result ;
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("mysum.wsdl");
$server->addFunction("mysum");
$server->handle();
that I can access from a php client:
$client = new SoapClient("http://www.my-uni-
project.info/joomla/components/com_jv_vm_soa/mysum.wsdl");
$params = array('n1' => '4', 'n2' => '8');
try {
$result = $client->__soapCall('mysum', array('parameters' => $params));
echo $result;
} catch (SoapFault $exception) {
echo $exception;
}
I tried to create a C# client so first I created a service reference "mysum", then on the form I added a button and a label and I added the following code for the button
private void button1_Click(object sender, EventArgs e)
{
mysum s = new mysum();
label1.Text = "" + s.mysum(2, 3);
}
Whe I run it I get this error:
Error 5 The type or namespace name 'mysum' could not be found (are you
missing a using directive or an assembly reference?)
The service is online
Thank you in advanced
John
Typically you can determine if you can resolve the problem using a directive by right-clicking on the object in question, in this case mysum, and seeing if you can 'Resolve Using ' where is the name of your directive.
I think your problem is that you are adding the service as a service reference instead of web service reference.
To add a web service reference
Add service reference
Hit the Advanced button on the window
Hit Add Web Reference
Enter the service url
Also,
Make sure you have added the System.Web.Services namespace reference in your project.
Hope it helps.
Background:
I'm in the process of creating a web service using ASP.NET 2.0. This web service provides another interface to an existing web form which contains selection boxes dynamically populated from a database.
My first draft of the web service accepted a string for each of these and then ensured that it was valid, throwing back an error if it wasn't. However the consumer of the web service has asked, since the possible values aren't likely to change all that often, that we provide enumerated values in the WSDL.
I am reluctant to create an enumeration with my web service code, so I have instead altered the generated WSDL file and instructed my web service to use that instead of inspecting my classes to generate it.
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://example.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://example.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://example.org/">
<s:element name="MyMethod">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="myClass" type="tns:MyClass" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="MyClass">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="MyString" type="tns:MyStringPossibleValues" />
</s:sequence>
</s:complexType>
<s:element name="MyMethodResponse">
<s:complexType />
</s:element>
<s:simpleType name="MyStringPossibleValues">
<s:restriction base="s:string">
<s:enumeration value="alpha" />
<s:enumeration value="bravo" />
</s:restriction>
</s:simpleType>
</s:schema>
</wsdl:types>
<wsdl:message name="MyMethodSoapIn">
<wsdl:part name="parameters" element="tns:MyMethod" />
</wsdl:message>
<wsdl:message name="MyMethodSoapOut">
<wsdl:part name="parameters" element="tns:MyMethodResponse" />
</wsdl:message>
<wsdl:portType name="ExternalAccessSoap">
<wsdl:operation name="MyMethod">
<wsdl:input message="tns:MyMethodSoapIn" />
<wsdl:output message="tns:MyMethodSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="ExternalAccessHttpGet" />
<wsdl:portType name="ExternalAccessHttpPost" />
<wsdl:binding name="ExternalAccessSoap" type="tns:ExternalAccessSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="MyMethod">
<soap:operation soapAction="http://example.org/MyMethod" 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="ExternalAccessSoap12" type="tns:ExternalAccessSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="MyMethod">
<soap12:operation soapAction="http://example.org/MyMethod" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
Webservice:
namespace Example.Service
{
[WebService(Namespace = "http://example.org/")]
[WebServiceBinding(
ConformsTo = WsiProfiles.BasicProfile1_1,
Location="ExternalAccess.wsdl",
Name="ExternalAccessSoap",
Namespace = "http://example.org/")]
[ToolboxItem(false)]
public class ExternalAccess : System.Web.Services.WebService
{
public class MyClass
{
public string MyString;
}
[WebMethod]
[SoapDocumentMethod(
Action = "http://example.org/MyMethod",
RequestNamespace = "http://example.org/",
Binding="ExternalAccessSoap")]
public void MyMethod(MyClass myClass)
{
}
}
}
The problem:
As the WSDL specifies an enumeration for MyString and the code specified a string type, ASP.NET does not manage to map the fields correctly.
Is there an attribute I can use to instruct the deserialiser to populate the string field with the value of the enumeration?
Regards,
Matt
Having gone through the process of creating a soap extension to do this for me I discovered that MyString wasn't actually being sent to my web service.
This was because the test application for this service was built in .NET also and, when building the request object, the MyStringSpecified property of the generated proxy class was overlooked. This then prevented the enumerated value being sent as part of the SOAP request.
When this property was set to true, the enumerated value was successfully assigned to the MyString field in the webservice.