|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem in sending Soap message with long Japanese strings
Hey All,
I have a client built using VC++ running on Windows which sends Soap messages to a web service deployed on Tomcat that uses Axis. The client is being localized in Japanese as well. Here comes the problem: When user enters a lot of doube-byte Japanese characters in the client UI then error occurs while sending the soap request. The error occurs when Finished() is called. This problem does not occur in following cases: - if user enters lesser number of characters as input - in English version. I am using InitWithComposer() method of SoapSerializer30 to compose the soap since the message may contain attachmetns too. DimeComposer30 is used in this method. Also, I noticed if I use Init() method instead of InitWithComposer. This problem does not occur Can somebody tell me where the problem is? The code is also listed below for reference. Soap toolkit 3.0 is being used and UTF-8 encoding is used in XML. The error returned is given below. ------------------------------------------------------------- - Exception: AxisFault faultCode: {http://xml.apache.org/axis/}Server.userException faultString: java.io.UTFDataFormatException: Expected byte 3 of 3-byte UTF-8 sequence. faultActor: null faultDetail: stackTrace: java.io.UTFDataFormatException: Expected byte 3 of 3-byte UTF-8 sequence. at org.apache.xerces.impl.io.UTF8Reader.expectedByte( Unknown Source) at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source) at org.apache.xerces.impl.XMLEntityScanner.load(Unkno wn Source) at org.apache.xerces.impl.XMLEntityScanner.scanConten t(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanContent(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(U nknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContextImp l.parse(DeserializationContextImpl.java:232) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:546) at org.apache.axis.Message.getSOAPEnvelope(Message.ja va:377) at org.apache.axis.server.AxisServer.invoke(AxisServe r.java:304) . . . Code: ------------------------------------- HRESULT hr; ISoapSerializerPtr pSerializer; ISoapReaderPtr pReader; hr = pSerializer.CreateInstance(__uuidof(SoapSerializer 30)); if(FAILED(hr)) return FALSE; IMessageComposerPtr Composer; hr = Composer.CreateInstance(__uuidof(DimeComposer30)); if(FAILED(hr)) return FALSE; pSerializer->InitWithComposer((IUnknown*)mpConnector->InputStream,Composer); pSerializer->StartEnvelope("","http://schemas.xmlsoap.org/soap/encoding",""); pSerializer->SoapAttribute("xsi","", "http://www.w3.org/2001/XMLSchema-instance","xmlns"); pSerializer->SoapAttribute("xsd","","http://www.w3.org/2001/XMLSchema","xmlns"); pSerializer->StartBody(""); pSerializer->StartElement("CheckIn", "", "http://schemas.xmlsoap.org/soap/encoding/", "ns1"); pSerializer->SoapAttribute("ns1" ,"","urn:OrionService","xmlns"); pSerializer->StartElement("command",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("ns2","", "http://schemas.xmlsoap.org/soap/encoding/","xmlns"); pSerializer->SoapAttribute("type","","ns2:Array","xsi"); //Format the command string CFormatter ObjFormat; if(_tcscmp(pidlData->szTitle, "")) { _stprintf(str,"-dis 1 dm_object title C \"%s\" U",pidlData->szTitle); ObjFormat.AddText(str); } //Add the command string array to soap request TCHAR strID[1000]; _stprintf(strID,"xsd:string[%d]",ObjFormat.GetItemCount()); pSerializer->SoapAttribute("arrayType","",strID,"ns2"); TCHAR *token; token = _tcstok( ObjFormat.GetString(), "\n"); while( token != NULL ) { pSerializer->StartElement("item",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("type",_bstr_t(),"xsd:string","xsi"); pSerializer->WriteString(token); pSerializer->EndElement(); token = _tcstok( NULL, "\n" ); } pSerializer->EndElement(); //Add file original file names to soap request pSerializer->StartElement("fileName",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("ns2","", "http://schemas.xmlsoap.org/soap/encoding/","xmlns"); pSerializer->SoapAttribute("type","","ns2:Array","xsi"); if (cDocumentType == 'R') // registerd _stprintf(strID,"xsd:string[%d]",0); else if (cDocumentType == 'S') // storted _stprintf(strID,"xsd:string[%d]",iDocCount); else if (cDocumentType == 'M') // multisheet _stprintf(strID,"xsd:string[%d]",iDocCount); pSerializer->SoapAttribute("arrayType","",strID,"ns2"); lpFiles= lpFilesList; if (cDocumentType == 'S') // storted { for(i = 0;i { pSerializer->StartElement("item",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("type","","xsd:string","xsi"); pSerializer->WriteString((lpFiles->szFileName+lpFiles->iOffset)); lpFiles= lpFiles->pNext; pSerializer->EndElement(); } } pSerializer->EndElement(); //Add files array to soaprequest pSerializer->StartElement("file",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("soapenc","", "http://schemas.xmlsoap.org/soap/encoding/","xmlns"); pSerializer->SoapAttribute("type","","soapenc:Array","xsi"); _stprintf(strID,"ns1URLataHandler[%d]",iDocCount); pSerializer->SoapAttribute("arrayType","",strID,"soapenc"); //DebugBreak(); FileAttach = new IFileAttachmentPtr[iDocCount]; for(i=0;i { FileAttach[i].CreateInstance(__uuidof(FileAttachment30)); pSerializer->StartElement("item",_bstr_t(),_bstr_t(),_bstr_t()); FileAttach[i]->FileName = sFileName[i]; pSerializer->AddAttachmentAndReference(FileAttach[i]); pSerializer->EndElement(); } pSerializer->EndElement(); //Locale pSerializer->StartElement("Locale",_bstr_t(),_bstr_t(),_bstr_t()); pSerializer->SoapAttribute("type","","xsd:string","xsi"); pSerializer->WriteString(msLocale); pSerializer->EndElement(); pSerializer->EndElement(); pSerializer->EndBody(); pSerializer->EndEnvelope(); pSerializer->Finished(); Hope to see the response soon. Thanks Rohit Sethi |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Problem in sending Soap message with long Japanese strings |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|