How to create soap webservice with attributes

34 views
Skip to first unread message

Lokesh Singhal

unread,
Mar 15, 2016, 5:44:01 AM3/15/16
to Membrane SOA Model
Hi, 

I want to create web service with attributes

as for example :

  <s11:Body>
    <ns1:getDocumentCount xmlns:ns1='http://document.service.oreo.sch.com/'>
      <scope>
        <brand>Sch</brand>
        <country>WW</country>
      </scope>

      <countBy countBy='all'></countBy >
      
    </ns1:getDocumentCount>
  </s11:Body>
</s11:Envelope>


how can i pass attribute countBy="all"  while creating soap request.

What I am doing is :

                    formParams.put("xpath:/getDocumentCount/scope/brand", "Sch");
   formParams.put("xpath:/getDocumentCount/scope/country", "WW");
   formParams.put("xpath:/getDocumentCount/countBy/", "");
      
   
   SOARequestCreator creator = new SOARequestCreator(wsdl, new RequestCreator(), new MarkupBuilder(writer));
   creator.setBuilder(new MarkupBuilder(writer));
   creator.setDefinitions(wsdl);
   creator.setFormParams(formParams);
   creator.setCreator(new RequestCreator());


However I am not successful. Please help me.

Thanks in advance
Lokesh

Thomas Bayer

unread,
Mar 15, 2016, 6:11:19 AM3/15/16
to soa-...@googlegroups.com
HI,
I think you can do something like:

formParams.put("xpath:/getDocumentCount/scope/@country", "WW");

using the @ sign. But attributes in Web Services is generally not a good
idea.

Cheers,
Thomas


Am 15.03.16 um 10:44 schrieb Lokesh Singhal:

Lokesh Singhal

unread,
Mar 15, 2016, 6:34:15 AM3/15/16
to Membrane SOA Model
Hi Thomas, 

I tried the way you said, 

like this
                    formParams.put("xpath:/getDocumentCount/scope/brand", "Schneider Electric");
   formParams.put("xpath:/getDocumentCount/scope/country", "WW");
   formParams.put("xpath:/getDocumentCount/countBy/countBy/@countBy", "all");
   formParams.put("xpath:/getDocumentCount/locale/isoCountry", "GB");
   formParams.put("xpath:/getDocumentCount/locale/isoLanguage", "en");
   formParams.put("xpath:/getDocumentCount/query/locales", "1555684");
   formParams.put("xpath:/getDocumentCount/query/searchString", "altivar 61");   //60212

to create the webservice :

  <s11:Body>
    <ns1:getDocumentCount xmlns:ns1='http://document.service.oreo.schneider.com/'>
      <scope>
        <brand>Schneider Electric</brand>
        <country>WW</country>
      </scope>
      <countBy countBy='all'></countBy >
      <locale>
        <isoCountry>GB</isoCountry>
        <isoLanguage>en</isoLanguage>
      </locale>
      <query>
        <locales>1555684</locales>
        <searchString>altivar 61</searchString>
      </query>
    </ns1:getDocumentCount>
  </s11:Body>
</s11:Envelope>


However, it created web service like this 

  <s11:Body>
    <ns1:getDocumentCount xmlns:ns1='http://document.service.oreo.schneider.com/'>
      <scope>
        <brand>Schneider Electric</brand>
        <country>WW</country>
      </scope>
      <locale>
        <isoCountry>GB</isoCountry>
        <isoLanguage>en</isoLanguage>
      </locale>
      <query>
        <locales>1555684</locales>
        <searchString>altivar 61</searchString>
      </query>
      <countBy />
    </ns1:getDocumentCount>
  </s11:Body>
</s11:Envelope>

Could you please help?? 

What I am doing wrong here?

Thanks
Lokesh

Lokesh Singhal

unread,
Mar 15, 2016, 6:38:20 AM3/15/16
to Membrane SOA Model
Hi Thomas, 

Thanks for help, I did that !!!

Thanks
Lokesh

Thomas Bayer

unread,
Mar 15, 2016, 6:39:51 AM3/15/16
to soa-...@googlegroups.com
Hi,
is your path right?


   formParams.put("xpath:/getDocumentCount/countBy/countBy/@countBy", "all");

try:

   formParams.put("xpath:/getDocumentCount/country/@countBy", "all");

Cheers,
Thomas


-- 
predic8 GmbH
Moltkestr. 40

53173 Bonn

http://predic8.de
Tel: +49 (0) 228 5552576-0
Fax: +49 (0) 228 5552576-50

Amtsgericht Bonn
HRB 16152
Geschäftsführer: Thomas Bayer
Am 15.03.16 um 11:34 schrieb Lokesh Singhal:
   formParams.put("xpath:/getDocumentCount/countBy/countBy/@countBy", "all");

Lokesh Singhal

unread,
Mar 15, 2016, 6:47:50 AM3/15/16
to Membrane SOA Model, in...@predic8.de
Yes Thomas, 
Corrected the path only, that worked !!!

Cheers 
Lokesh
Reply all
Reply to author
Forward
0 new messages