Resolved Empty Response From C# .net Webservice

Rutger Olthuis

New Member
Hi,
I've had a long break from developing with Progress. Things like Prodatasets are pretty new for me, so my problem might be related to my lack of understanding the prodataset, but I have the feeling I'm doing something else wrong.

I'm trying to call a number of webservices created in C#. I test them both mocked in soapUI and with an actual Visual studio running the webservice.
When I have a string as response, regardless of my input (class or just a string), all works fine.
When I have a class as a response (bprowsdldoc generates some nice datasets for me) and I try to save the dataset as an XML file, I always get an empty (except for some namespace declarations) XML file.
I can see in the VS2012 debugger that my request is recieved and the response is generated.
What am I doing wrong here?


Code:
DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hIService1 AS HANDLE NO-UNDO.

DEFINE TEMP-TABLE composite NO-UNDO
   NAMESPACE-URI "http://schemas.datacontract.org/2004/07/WcfService2"
   FIELD BoolValue AS LOGICAL
   FIELD StringValue AS CHARACTER .

DEFINE DATASET compositeDset NAMESPACE-URI "http://schemas.datacontract.org/2004/07/WcfService2"
   XML-NODE-TYPE "HIDDEN"
   FOR composite.

DEFINE TEMP-TABLE GetDataUsingDataContractResult NO-UNDO
   NAMESPACE-URI "http://schemas.datacontract.org/2004/07/WcfService2"
   FIELD BoolValue AS LOGICAL
   FIELD StringValue AS CHARACTER .

DEFINE DATASET GetDataUsingDataContractResuDset NAMESPACE-URI "http://schemas.datacontract.org/2004/07/WcfService2"
   XML-NODE-TYPE "HIDDEN"
   FOR GetDataUsingDataContractResult.

RUN ConnectWS.
RUN GetDataUsingDataContract.
FINALLY:
        RUN CloseAll.   
END FINALLY.

PROCEDURE ConnectWS:
   CREATE SERVER hWebService.
   hWebService:CONNECT("-WSDL 'http://localhost:59103/Service1.svc?wsdl'").
   RUN IService1 SET hIService1 ON hWebService.
END PROCEDURE.
PROCEDURE GetDataUsingDataContract:
  DEFINE VARIABLE a AS LOGICAL NO-UNDO.
  CREATE composite.
  ASSIGN
     composite.BoolValue = true
     composite.StringValue = 'Mijn naam is Rutger'
     .
  RUN GetDataUsingDataContract IN hIService1(INPUT DATASET compositeDset, OUTPUT DATASET GetDataUsingDataContractResuDset).
  a = DATASET GetDataUsingDataContractResuDset:write-xml("file","C:\OpenEdge\114\WRK\crowdfund\test.xml",TRUE,'UTF-8',?,false,false).
END PROCEDURE.
PROCEDURE CloseAll:
   DELETE OBJECT hIService1.
   hWebService:DISCONNECT().
   DELETE OBJECT hWebService.
END PROCEDURE.
 

Rutger Olthuis

New Member
oke, no replies so I have to reply myself ;)

I created a ticket with Progress support and they came with a number of causes and solutions.
The major cause was that the namespaces in the webservices did not map to the namespaces generated by the bprowsdldoc tool. The class body had a different namespace than the class fields while OpenEdge generated code for one namespace.
There are three solutions for this.
1. A bad solution is to manually change the namespace declaration in the OpenEdge code to match that of the webservice. Support advised against this solution because when you save the reponse xml to file, the namespaces are all over the place.
2. A good solution that cannot always be performed is to enforce the correct namespaces on the WS side.
Code:
[DataContract(Namespace = "mynamespace")]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";

[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}

[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
The code generated by bprowsdldoc then looks like:
Code:
DEFINE TEMP-TABLE composite NO-UNDO
NAMESPACE-URI "mynamespace"
FIELD BoolValue AS LOGICAL
FIELD StringValue AS CHARACTER .

DEFINE DATASET compositeDset NAMESPACE-URI "mynamespace"
XML-NODE-TYPE "HIDDEN"
FOR composite.

DEFINE TEMP-TABLE GetDataUsingDataContractResult NO-UNDO
NAMESPACE-URI "mynamespace"
FIELD BoolValue AS LOGICAL
FIELD StringValue AS CHARACTER .

DEFINE DATASET GetDataUsingDataContractResuDset NAMESPACE-URI "mynamespace"
XML-NODE-TYPE "HIDDEN"
FOR GetDataUsingDataContractResult.
3. The third option is to not use Datasets, but use the old style bprowsdldoc -show100style <WSDL URL> This generates service calls with longchars instead of prodatasets.

OpenEdge support will create a bug issue with their backend to fix inconsistency between the actual wsdl and the generated code in a servicepack or future release..
 
Top