Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Two WSDL questions, header not added

    Hello,

    I'm integrating with the following webservice, of an accounting application:
    https://c1.twinfield.com/webservices...sxml.asmx?wsdl

    From their documentation, I should be able to send the following SOAP envelope:
    Code:
    <?xml version="1.0" encoding="utf-16"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XmlSchema-instance" xmlns:xsd="http://www.w3.org/2001/XmlSchema">
    <soap:Header>
     <Header MyAttribute="" xmlns="http://www.twinfield.com/">
       <SessionID>61587139-7938-4dca-84f7-625524d7a8fa</SessionID> 
     </Header>
    </soap:Header> 
    <soap:Body>
     <ProcessXmlString xmlns="http://www.twinfield.com/"> 
       <xmlRequest><![CDATA[<list><type>offices</type></list>]]></xmlRequest>
     </ProcessXmlString> 
    </soap:Body>
    </soap:Envelope>
    When I try to set the SessionID in the header using this code:
    Code:
    WSRequest req = new WSRequest();
    Map<String,Object> values = new HashMap<String,Object>();
    values.put("SessionID", sessionId);
    
    req.setHeaderData(values);
    
    service.callOperation("ProcessXmlString", values, "//tf:ProcessXmlStringResult", new WebServiceCallback(){
    			@Override
    			public void execute(Object[] data, JavaScriptObject xmlDoc,
    					RPCResponse rpcResponse, JavaScriptObject wsRequest) {
                            }, req);
    I get the following warning:
    Code:
    [ERROR] [generatedcode] - 10:10:31.261:MUP0:WARN:XSElement:ProcessXmlString:headerData passed for SOAP header partName: SessionID, no schema available, not outputting
    The wsdl url does correctly describe the SessionID type in the header right? The developer console's 'generate sample request message' also ignores the SessionID. What am I doing wrong?

    A second question I have is: this webservice has a 'free form xml body', eg, everything inside the element <xmlRequest> can contain any form of XML . If I send this, it gets escaped. Is there a way to prevent escaping? (so if I understand it correctly the webservice is kind of under-specified)

    Hope someone can help me, i'm not so experienced with SOAP.
    Last edited by Sytematic; 21 Oct 2012, 00:18. Reason: indenting

    #2
    First question: since this webservice has taken the odd step of having it's own <Header> element immediately under SOAP's <Header> element, you need to arrange your header data with the same nesting: a Map containing a key "Header" whose value is another Map with the key "SessionID".

    About the freeform XML thing: yes that's terrible design and misses the entire point of WSDL.

    To work around this, instead of trying to pass an XML String directly, you should pass data that will become the required XML string when serialized via DataSource.xmlSerialize().

    Comment

    Working...
    X