consume nav webservice in navision

xiaosimonxiaosimon Member Posts: 2
edited 2011-10-13 in NAV Three Tier
hi,guys,i encounter a fucky problem.

i published my webservice in one navision server,and try to consume it from another.i will describe them as server A and server B.

my code is:

OnRun()
gFncDistribute('1001','9997,010105010101');
//gFncDistribute('1001','9998,0101020601');

gFncDistribute(pCodType : Code[10];pTxtNo : Text[50]) RTxtMessage : Text[30]


CASE pCodType OF
'1000':
BEGIN
pTxt1:=SELECTSTR(1,pTxtNo);
pTxt2:=SELECTSTR(2,pTxtNo);
pTxt3:=SELECTSTR(3,pTxtNo);
pTxt4:=SELECTSTR(4,pTxtNo);
pTxt5:=SELECTSTR(5,pTxtNo);
gFncVariantCheck(pTxt1,pTxt2,pTxt3,pTxt4,pTxt5);
END;

'1001':
BEGIN
pTxt1:=SELECTSTR(1,pTxtNo);
pTxt2:=SELECTSTR(2,pTxtNo);
gFncVariantRec(pTxt1,pTxt2);
END;
END;
//MESSAGE(gTxtReturnedStr);



IF ISCLEAR(lAutHttpLink) THEN
CREATE(lAutHttpLink,TRUE,TRUE);
IF ISCLEAR(gautXmlDoc) THEN CREATE (gautXmlDoc);
IF ISCLEAR(gAutReturnXmlDoc) THEN CREATE (gAutReturnXmlDoc);

tempblob.Blob.CREATEOUTSTREAM(lOutStream);
lOutStream.WRITETEXT('<?xml version="1.0" encoding="gbk" ?> ');
lOutStream.WRITETEXT('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/&quot; '+
'xmlns:nav="urn:microsoft-dynamics-schemas/codeunit/son2father">');
lOutStream.WRITETEXT('<soap:Header/>');
lOutStream.WRITETEXT('<soap:Body><nav:Gfncinteract>');
lOutStream.WRITETEXT('<nav:pin><![CDATA[ ');
gBtxtSend.WRITE(lOutStream);
lOutStream.WRITETEXT(']]></nav:pin>');
lOutStream.WRITETEXT('<nav:pout><![CDATA[');
gBtxtReturn.WRITE(lOutStream);
lOutStream.WRITETEXT(']]></nav:pout>');
lOutStream.WRITETEXT('</nav:Gfncinteract></soap:Body></soap:Envelope>');

tempblob.CALCFIELDS(tempblob.Blob);
tempblob.Blob.CREATEINSTREAM(lInStream);
CREATE(locautXmlDocReq);

locautXmlDocReq.load(lInStream);
//locautXmlDocReq.loadXML(FORMAT(gBtxtSend));
locautXmlDocReq.save('C:\request.xml');

lAutHttpLink.open('post','http://9.100.1.98:7047/DynamicsNAV/WS/ZMMC/Codeunit/son2father',0,
'zmmc\crmadmin','1234567');
//lAutHttpLink.open('post','http://9.110.1.93:7047/dynamicsnav/ws/XAZJ/Codeunit/father2son',0,'zmmc\ecadmin','1234567');

//;charset=utf-8
lAutHttpLink.setRequestHeader('Content-Type','text/xml;charset=gbk');

lAutHttpLink.setRequestHeader('SOAPAction','urn:microsoft-dynamics-schemas/codeunit/son2father/Gfncinteract');
lAutHttpLink.send(locautXmlDocReq);

//gautXmlDoc:=lAutHttpLink.responseXML;
//gautXmlDoc.load(lAutHttpLink.responseXML); // Loading reply from Webservice and saving it for reference
//gautXmlDoc.save('C:\response.xml');
//MESSAGE(FORMAT(lAutHttpLink.readyState));

IF FORMAT(lAutHttpLink.status)<>'200' THEN
BEGIN
//XMLNode:=gautXmlDoc.selectSingleNode('s:Envelope/s:Body/s:Fault/detail/string');
//ERROR(FORMAT(XMLNode.text));
ERROR(FORMAT(lAutHttpLink.status));
END;

the problem is when the encoding=utf-8 and there are no chinese character in the bigtext ,i can send message from server A to server B. but if there is any chinese character,i will get an error like this:

The call to member send failed. msxml3.dll returned the following message: system error: -1072896760.

then i change the encoding to gbk like the code above,but i get another problem. the response status is 400,it seems i can't make the connection. when i change the ip ('http://9.100.1.98:7047/DynamicsNAV/WS/ZMMC/Codeunit/son2father')to domain('http://testserver.zmmc.com.cn:7047/DynamicsNAV/WS/ZMMC/Codeunit/son2father'), then response status changed to 401. seems the username and password was worng,it's really puzzled me

can anybody know what the problem is? pls help me,thank you

(i searched the forum for one week,and i found nothing)
Sign In or Register to comment.