NAV web service - passing parameter problem on SOAP function

chuan214chuan214 Member Posts: 6
edited 2013-10-18 in NAV Three Tier
Hi,

I'm calling a Web Service from within NAV as follows:
CREATE(locautXmlDoc,FALSE,TRUE);
abc := 'jiki';
locautXmlDoc.async := FALSE;
locautXmlDoc.loadXML(  
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >'+
'<soap:Body>' +
'<sendToSCTee xmlns:Temp="http://tempuri.org/">' +
'<SubjectSC>'+abc+'</SubjectSC>' +
'</sendToSCTee>'+
'</soap:Body>' +
'</soap:Envelope>');

and the web service method code is as code below
public string sendToSCTee(string SubjectSC)
        {
            return smtpctrl.SendEmail("ab@xxx.com", null, null, IMailPriority.Normal, SubjectSC, IMailFormat.Html, "Testing", null, "CRONUS International Ltd_");
        }

This is send email function by using NAV code calling web services. It is work on sending email by that codes above, however, i can't pass parameter of "SubjectSC" to that function.

Does anyone have any ideas on what could be wrong? ](*,)

Thanks in advance.

Comments

  • Nagaraju17Nagaraju17 Member Posts: 12
    Create http connection like..


    CREATE(XMLHttpConn,TRUE,TRUE);
    XMLHttpConn.open(" Method name",Web Service URL", FALSE,HTTP Connection UserName", HTTP Connection Password");

    XMLHttpConn.setRequestHeader('Host',HTTP Connection Host Name");
    XMLHttpConn.setRequestHeader('SOAPAction',"Web Service Namespace" +
    "Request Web Service Method");
    XMLHttpConn.setRequestHeader('Content-Type',"HTTP Request Content-Type");
    XMLHttpConn.send(locautXmlDoc);
  • chuan214chuan214 Member Posts: 6
    my coding is like that
    CREATE(locautXmlHttp,true,TRUE);
    locautXmlHttp.open('POST','http://localhost:8282/siweb/WebServices/prq.asmx',0);
    locautXmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
    locautXmlHttp.setRequestHeader('SOAPAction','http://tempuri.org/sendToSCTee');
    
    locautXmlHttp.send(locautXmlDoc);  
    

    how do i modify for the code above?
  • chuan214chuan214 Member Posts: 6
    Nagaraju17 wrote:
    Create http connection like..


    CREATE(XMLHttpConn,TRUE,TRUE);
    XMLHttpConn.open(" Method name",Web Service URL", FALSE,HTTP Connection UserName", HTTP Connection Password");

    XMLHttpConn.setRequestHeader('Host',HTTP Connection Host Name");
    XMLHttpConn.setRequestHeader('SOAPAction',"Web Service Namespace" +
    "Request Web Service Method");
    XMLHttpConn.setRequestHeader('Content-Type',"HTTP Request Content-Type");
    XMLHttpConn.send(locautXmlDoc);
    i try by this way, but the variable result still the same, cant passing parameters value to the method also.
  • rdebathrdebath Member Posts: 383
    Your sendToSCTee and SubjectSC elements are using the default namespace, the tag 'xmlns:Temp="http://tempuri.org/"' is just defining a namespace not using it.

    I think web services more or less require namespaces to be set on all elements; perhaps you should remove the ':Temp' part.
Sign In or Register to comment.