Example on converting return types to String?

19 views
Skip to first unread message

Yasir K

unread,
Mar 28, 2014, 7:47:49 AM3/28/14
to wsf-...@googlegroups.com
This may sound like a noob question on programming but i'm used to coding in VS and not sure how to do this in staff/c++

When staff generates code based on a WSDL, it creates 'types' for the function parameters and return types, for example below:

::BasicConnect BasicConnect;
    const ::BasicConnectResponse& BasicConnectResponse = pService1->BasicConnect(BasicConnect);


in  my service that is hosted on .NET/Azure, BasicConnect is just an integer and the response type is also an integer.

Can anyone help me in figuring out how I can convert the response to an integer or string and also how to build the payload for sending the function parameter? Not having intellisense is a little awkard. :)


my service is hosted here:

http://d2a4ftl.cloudapp.net/D2AService.svc?wsdl



Dmitry Utkin

unread,
Mar 28, 2014, 9:04:46 AM3/28/14
to wsf-...@googlegroups.com
Hi,

I looked into your service. .NET generates WSDL a little strange. If you write service operation like this:

int BasicConnect(int value) {...}

it will generate WSDL for the service and xsd files for requests/responses(and some other xsds) like that:

in wsdl:
   <wsdl:message name="D2AService_BasicConnect_InputMessage">
      <wsdl:part name="parameters" element="tns:BasicConnect" />
   </wsdl:message>

   <wsdl:message name="D2AService_BasicConnect_OutputMessage">
      <wsdl:part name="parameters" element="tns:BasicConnectResponse" />
   </wsdl:message>
 
in xsd0.xsd:
   <xs:element name="BasicConnect">
      <xs:complexType>
         <xs:sequence>
            <xs:element minOccurs="0" name="i" type="xs:int" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>

   <xs:element name="BasicConnectResponse">
      <xs:complexType>
         <xs:sequence>
            <xs:element minOccurs="0" name="BasicConnectResult" type="xs:int" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>

One strange thing in generated wsdl is minOccurs="0" - element is optional and it will be interpreted by staff_codegen as staff:Optional<int> which is right.

Staff codegen interprets each file (wsdl or xsd) as separate .h file and for simple .NET service with few of operations you will see multiple headers.

Also unwrapping for types which is defined in external xsd is not possible and you'ii see:

::BasicConnectResponse BasicConnect(const ::BasicConnect& BasicConnect);

instead of:

::staff::Optional<int> BasicConnect(const ::staff::Optional<int>& BasicConnect);


To see service interface as expected you must fix generating of WSDL on .NET side:



To mark requests/responses as "required" not "optional" try this http://thorarin.net/blog/post/2010/08/08/Controlling-WSDL-minOccurs-with-WCF.aspx




пятница, 28 марта 2014 г., 15:47:49 UTC+4 пользователь Yasir K написал:

Yasir K

unread,
Mar 28, 2014, 4:36:19 PM3/28/14
to wsf-...@googlegroups.com
Dimitry, thanks so much for the reply, this really helped me in getting things to finally work.

I ended up invoking the service correctly by using the optional <int> like so:

  int basicResult = BasicConnectResponse.BasicConnectResult;

the basicConnectResult enum under the response variable was accessible so this worked.

i'll look into the link you shared to fix the .NET WSDL generation.

btw, am really getting to like staff a lot---thanks for the support dimitry.
Reply all
Reply to author
Forward
0 new messages