0

I want to add the following content to the Soap request body when webservice is invoked.

<foo bar="baz">bar</foo>

I tried to update the generated code by the WSDL file.

public class MyService {
   public class bar {
      public String bar;
      private String[] bar_type_info = new String[] {'bar','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
      private String[] apex_schema_type_info = new String[] {'http://schema.myservice.com', 'false', 'false'};
      private String[] field_order_type_info = new String[] {'bar'};
   }

   public class foo {
      public MyService.bar bar;
      public String a;
      private String[] bar_type_info = new String[] {'bar','http://schema.myservice.com','bar','0','1','true'};
      private String[] a_att_info = new String[] {'a'};
      private String apex_schema_type_info = new String[] {'http://schema.myservice.com','false','false'};
      private String[] field_order_type_info = new String[] {'bar'};
   }
}

I only can get this message.

<foo a="b"><bar>baz</bar></foo>

How can I change the Apex code to remove <bar> tag from the SOAP request body?

  • 1
    please post the code you are using? – Mohith Shrivastava Feb 21 '14 at 16:11
  • Yes and a sample of your WSDL where the foo type is defined? – Andrew Fawcett Feb 21 '14 at 17:54
  • @AndrewFawcett I am using WSDL file which is big one. So I just updated a sample code that can generate <foo a="b"><bar>baz</bar></foo> request. But I don't want to have <bar> tag. Do you have a WSDL file that can get my expect Request body? – Jair Feb 22 '14 at 7:04
  • Can you share the WSDL via Gist? gist.github.com it's really hard to modify the generated code, even though i consider myself reasonably familar with it, it's better to look at this from the view point of the XML Schema within the WSDL, so uploading as Gist and pointing to the types in their will definitely help here. – Andrew Fawcett Feb 22 '14 at 8:08
3

This is just eyeballing, but I think what you're intending to do is the code below (warning: freehanded, no validating since I don't have the rest of your class). Instead you have created a child element named bar instead, and an attribute named a on the parent element, foo. You wanted an attribute(string) named bar.

public class MyService {
   public class foo {
      public String bar;
      private String[] bar_att_info = new String[] {'bar'};
      private String[] apex_schema_type_info = new String[] {'http://schema.myservice.com', 'false', 'false'};
      private String[] field_order_type_info = new String[] {'bar'};
   }
}
  • Thanks your post. I just tested your code. The request body is <foo><bar>baz</bar></foo> which is not my expect result <foo a="b">baz</foo>. – Jair Feb 22 '14 at 7:36
  • Can you send the code you're using to execute the web service (minus all your personal stuff)? – drakored Feb 22 '14 at 7:57
  • Actually, try the updated code. The key is whether you use VAR_att_info or VAR_type_info I believe. – drakored Feb 22 '14 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.