NetTalk Central

Author Topic: WebService Problem  (Read 6633 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
WebService Problem
« on: March 12, 2013, 04:51:53 PM »
i received this error when load webservice:
the PacketReceived return this:

HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Length: 53
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Wed, 13 Mar 2013 15:18:31 GMT
Connection: close

Request format is invalid: text/xml; charset=utf-8.

My Code:

In saveTweakSettings:

 ! this is a good embed point to set all the xml and soap settings that we require for
  ! this service.

  xmlFile.SOAPEnvelope     = 1                 ! tells xFiles to wrap the XML in a SOAP envelope
  xmlFile.SaveEncoding = 'utf-8'                 ! default is 'ISO-8859-1'
  xmlFile._pfileBoundary = ''                    ! no file boundary tag required by this server
  xmlFile._pRecordBoundary = 'CRIMWebService'
  xmlFile.TagCase = XF:CaseAsIs

  ! the following are default values in XFiles, so don't actually need to be set here,
  ! but are included so you can see what they are, and override them if you wish.

  xmlFile.SOAPEnvelopeBoundaryAttribute = 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'
  xmlFile.SOAPEnvelopeBoundary  = 'soap:Envelope'
  xmlFile.SOAPBodyBoundary      = 'soap:Body'

In my Button

PacketReceived = ''

! Construct the SOAP packet to make a request of the web service
Forecast_Date = FORMAT(Glo:InterestDate,@D06)
PinNumber = Glo:PinNumber
    
xmlFile.save(RequestGroup)
PostString = xmlFile.xmldata

net.CanUseProxy = 1           ! Can use a proxy
net.HeaderOnly   = 0            ! We want the whole page
      
net.AsyncOpenUse = 1          ! Use AsyncOpen 12 seconds (recommended)
net.AsyncOpenTimeOut = 1200   ! Up to 12 seconds to connect
      
net.InActiveTimeout = 9000    ! Set IdleTimeout 90 seconds
net.ConnectionKeepAlive = 0
      
net.ContentType = 'text/xml; charset=utf-8'                              
net.AcceptEncoding = ''
net.ContentLength = Len(Clip(PostString))

! Set the SOAPAction header to tell the web service which method to execute
net.customheader = 'SOAPAction: "http://www.crimpr.net/ws/crimservice.asmx"'

        ! The packet is contstructed, so you can post it to the webservice
PacketSent = PostString

SetCursor(Cursor:Wait)    
net.Post('http://www.crimpr.net/ws/crimservice.asmx/CRIMWebService?', Clip(PostString))
If net.Error
    Message ('Could not be post the SOAP request to this web service. Error ' & net.Error |
        & ': ' & net.InterpretError())
    SetCursor()
end

In PageReceived:

if Self.PageLen > 0
    PacketReceived = self.Page   
    SETCLIPBOARD(PacketReceived)
    DO Process
    ! xml.load(resultGroup,self.page,len(clip(self.page)))
    display()
End
SetCursor()
« Last Edit: March 12, 2013, 05:34:25 PM by osquiabro »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: WebService Problem
« Reply #1 on: March 12, 2013, 09:35:23 PM »
If you log the "outgoing packet" what does it look like?
(ie - put the following code in the .Process method, before the parent call - grab the result from debugview, and post it here.)

net._trace(clip(self.packet.bindata)

Cheers
Bruce


osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #2 on: March 13, 2013, 05:20:11 AM »
nothing occurs in process method, only the same error:

00000000   0.00000000   [12264] [netTrace][thread=2]    
00000001   1.53007126   [12264] [netTrace][thread=2] HTTP/1.1 500 Internal Server Error    
00000002   1.53007126   [12264] Cache-Control: private    
00000003   1.53007126   [12264] Content-Length: 53    
00000004   1.53007126   [12264] Content-Type: text/plain; charset=utf-8    
00000005   1.53007126   [12264] Server: Microsoft-IIS/7.5    
00000006   1.53007126   [12264] X-AspNet-Version: 2.0.50727    
00000007   1.53007126   [12264] X-Powered-By: ASP.NET    
00000008   1.53007126   [12264] Date: Wed, 13 Mar 2013 15:18:31 GMT    
00000009   1.53007126   [12264] Connection: close    
00000010   1.53007126   [12264]     
00000011   2.81954670   [12264] [netTrace][thread=2] Request format is invalid: text/xml; charset=utf-8.    

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #3 on: March 13, 2013, 05:30:12 AM »
i have this code that work for call a webservice this is via activeX and i try to convert to use nettalk template:

?XMLHTTP_Object{PROP:ReportException} = True          ! *** Turn on for debugging
?XMLHTTP_Object{PROP:Create} = 'Microsoft.XMLHTTP'
?XMLHTTP_Object{'open("GET","http://www.crimpr.net/ws/crimservice.asmx/CRIMWebService?Forecast_Date='&FORMAT(Glo:InterestDate,@D06)&'&PinNumber='&Glo:PinNumber&'", 0)'}
        ?XMLHTTP_Object{'setRequestHeader("Content-Type","text/xml")'}
        ?XMLHTTP_Object{'send()'}   ! I previously loaded xmlstring
       
        IF ?XMLHTTP_Object{'status'} <> 200
           MESSAGE('Server not available or Timeout','ALERT')
           Do ClearFields
           EXIT
        END

       ! Read response
        ?XMLDOM_Object{PROP:ReportException} = True          ! *** Turn on for debugging
        ?XMLDOM_Object{PROP:Create} = 'Microsoft.XMLDOM'
        ?XMLDOM_Object{'async'} = 0              ! false
        ?XMLDOM_Object{'validateOnParse'}  = 0   ! false   - this disables testing for a "well formed xml file" (I believe based on the DTD)
        ?XMLDOM_Object{'resolveExternals'} = 0   ! false   - this was necessary to stop the error caused by an external DTD

        ?Wait{PROP:TEXT}='* Loading Complete *'
        SETCURSOR()
        TimeStop = CLOCK()
        TotalTime = (TimeStop-1) - (TimeStart-1)+1
        IF TotalTime < 1 THEN TotalTime += 8640000.
        ?String8{prop:text}='Time Execute: '& FORMAT(TotalTime,@t4)

        Loc:XMLResponse = ?XMLHTTP_Object{'ResponseText'}
        LoadStatus      = ?XMLDOM_Object{'load(' & ?XMLHTTP_Object{'responseXML'} & ')'}

        IF LoadStatus
           IF NOT xmlFile.xmlData &= null
                DISPOSE(xmlFile.xmlData)
           END
           xmlFile.xmlData    &= new STRING(200000)
           xmlFile.xmlData     = Loc:XMLResponse
           xmlFile.xmlDataLen  = LEN(Clip(xmlFile.xmlData))

           xmlFile.loadFromString = 1
           Loc:FileBoundary       = ''
           Loc:RecordBoundary     = 'ErrorMessage'
           xmlFile.Load(ErrorMessage,Loc:XMLResponse,LEN(Loc:XMLResponse),Loc:FileBoundary,Loc:RecordBoundary)

           IF ErrorMsg = ''
              Do VersionNumber
              Do AccountInformation
              Do ContactAddressInfo
              Do PropertyAddressInfo
              Do BillsInfo
              xmlFile.loadFromString = 0
              DO UpLoadData
              xmlFile.FreeQueueData()
           ELSE
               MESSAGE(ErrorMsg)
              DO ClearFields
           END
           Display()
        ELSE
          MESSAGE('An error occurred attempting to load the XML response file.||Process cancelled.')
        END
        DISPLAY

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: WebService Problem
« Reply #4 on: March 13, 2013, 05:44:49 AM »
sorry, my mistake.
I meant you need to put that trace in the .SEND method
Process is for incoming (which we know) - it's the outgoing in .SEND that I'm interested in.

So add to .SEND and then post that here.
the answer I suspect will be fairly obvious from that.

cheers
Bruce




osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #5 on: March 13, 2013, 08:12:25 AM »
return this:

00000000   0.00000000   [15216] [netTrace][thread=2] POST /ws/crimservice.asmx/CRIMWebService HTTP/1.0    
00000001   0.00000000   [15216] Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*    
00000002   0.00000000   [15216] Accept-Language: en    
00000003   0.00000000   [15216] Content-Type: text/xml; charset=utf-8    
00000004   0.00000000   [15216] User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729; .NET4.0C)    
00000005   0.00000000   [15216] Host: www.crimpr.net    
00000006   0.00000000   [15216] Content-Length: 384    
00000007   0.00000000   [15216] Connection: Close    
00000008   0.00000000   [15216] SOAPAction: "http://www.crimpr.net/ws/CRIMService.asmx"    
00000009   0.00000000   [15216]     
00000010   0.00000000   [15216] <?xml version="1.0" encoding="utf-8"?>    
00000011   0.00000000   [15216] <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">    
00000012   0.00000000   [15216] <soap:Body>    
00000013   0.00000000   [15216]   <CRIMWebService>    
00000014   0.00000000   [15216]     <FORECAST_DATE>13/03/2013</FORECAST_DATE>    
00000015   0.00000000   [15216]     <PINNUMBER>660-64-5369</PINNUMBER>    
00000016   0.00000000   [15216]   </CRIMWebService>    
00000017   0.00000000   [15216] </soap:Body>    
00000018   0.00000000   [15216] </soap:Envelope>    

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #6 on: March 13, 2013, 05:34:35 PM »
i have advance with this problem, first when use

xmlFile.save(RequestGroup)
PostString = xmlFile.xmldata

generate this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CRIMWebService>
  <FORECAST_DATE>13/03/2013</FORECAST_DATE>
   <PINNUMBER>660-64-5369</PINNUMBER>
</CRIMWebService>
</soap:Body>
</soap:Envelope>

and don't work if i create a postring manually then read the webservice:

PostString = '<?xml version="1.0" encoding="utf-8"?>'&|
                    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'&|
                      '<soap:Body>'&|
                        '<CRIMWebService xmlns="http://tempuri.org/">'&|
                          '<Forecast_Date>'&FORMAT(Glo:InterestDate,@D06)&'</Forecast_Date>'&|
                          '<PinNumber>'&clip(Glo:PinNumber)&'</PinNumber>'&|                         
                        '</CRIMWebService>'&|
                      '</soap:Body>'&|
            '</soap:Envelope>'

but i have another problem i can't read the response in my other process i use a GET to read a webservice, is possible to use a GET with nettalk??

This is the response with nettalk and POST:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Length: 1388
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 14 Mar 2013 22:14:29 GMT
Connection: close

<?xml version="1.0" encoding="utf-8"?><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:Body><CRIMWebServiceResponse xmlns="http://tempuri.org/">

<CRIMWebServiceResult>
<Hansenv7Request>
Forecast_Date>13/03/2013</Forecast_Date><PinNumber>660-64-5369</PinNumber></Hansenv7Request><Version><WebServicesVersion>5.0.0.0</WebServicesVersion></Version><connectionstring><DataSource>CRIMDB</DataSource></connectionstring><AccountInfo><RunDate>2013-03-13T00:00:00-04:00</RunDate><AccountKey>1388476</AccountKey><AccountClass>PERS</AccountClass><ContactName>INFORMATION SOLUTIONS &amp; TECNOLOGIES INC</ContactName><ContactID>660-64-5369</ContactID><ContactAddress><ADDR1>PMB 274</ADDR1><ADDR2>PO BOX 6022</ADDR2><CITY>CAROLINA</CITY><STATE>PR</STATE><ZIP>00984-6022</ZIP></ContactAddress><PropertyAddress><SubdivisionName /><StreetType /><StreetName /><Town /><StreetAddress /><StreetDirection /><Suite /><City>CAROLINA</City><Zipcode /></PropertyAddress></AccountInfo><BILLS><BILL><BLKEY>0</BLKEY><BLNO>0</BLNO><PrincipalUnpaidTax>0</PrincipalUnpaidTax><Discount>0</Discount><Penalty>0</Penalty><Interest>0</Interest><Surcharge>0</Surcharge><AmountDue>0</AmountDue></BILL></BILLS><ErrorMessage /></CRIMWebServiceResult></CRIMWebServiceResponse></soap:Body></soap:Envelope>

the response have a values that i need to read example:
     Loc:FileBoundary       = ''
    Loc:RecordBoundary     = 'AccountInfo'
     xmlFile.Load(AccountInfo,self.Page,LEN(self.Page),Loc:FileBoundary,Loc:RecordBoundary) 
but don't work

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #7 on: March 13, 2013, 06:23:39 PM »
found the problem for read the result, in LoadTweakSettings comment :

!xmlFile._pfileBoundary = ''
!xmlFile._pRecordBoundary = 'CRIMWebServiceResponse'

and add this  before load a xmlfile:

xmlFile.tagcase = xf:caseAny


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: WebService Problem
« Reply #8 on: March 14, 2013, 12:52:10 AM »
so - is there still a problem communicating with the service?

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #9 on: March 14, 2013, 02:00:05 AM »
i read successfully the web service..

but when use this code no:

xmlFile.save(RequestGroup)
PostString = xmlFile.xmldata

when create a posstring manually work.

i don't if the upper case of xml is a problem, this is case sensitive??

Bruce is possible to use GET for call a webservice with nettalk??
« Last Edit: March 14, 2013, 02:37:29 AM by osquiabro »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: WebService Problem
« Reply #10 on: March 14, 2013, 06:37:29 AM »
>>I don't if the upper case of xml is a problem, this is case sensitive??

yes, xml is case sensitive.
perhaps do
xmlFile.TagCase = xf:CaseUpper
before your call to xmlFile.Save

<< Bruce is possible to use GET for call a webservice with nettalk??

if the service supports the use of GET instead of POST, then yes. Usually parameters are added to the URL in the case of GET. The name of the NetWebClient method is FETCH instead of POST.

But of course this depends on if the service supports this approach.

cheers
Bruce

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: WebService Problem
« Reply #11 on: March 14, 2013, 08:57:03 AM »
i try this code but always save xml in uppercase:

xmlFile.TagCase = xf:CaseAsIs
xmlFile.save(RequestGroup)

PostString = xmlFile.xmldata
message(PostString)


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CRIMWebService>
  <FORECAST_DATE>13/03/2013</FORECAST_DATE>
   <PINNUMBER>660-64-5369</PINNUMBER>
</CRIMWebService>
</soap:Body>
</soap:Envelope>

bruce2

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Email
Re: WebService Problem
« Reply #12 on: March 14, 2013, 10:58:19 PM »
For CaseAsIs to work, the fields in the structure need an External Name, with the correct case.
otherwise the "label" is used (which to the compiler is always uppercase)

eg


Forecast_date  string(20),name('Forecast_Date')
PinNumber      long,name('PinNumber')


Cheers
Bruce