view · edit · sidebar · attach · print · history




  • Port to use the rack based SBSM
  • Keep in Mind



Port to use the rack based SBSM

Trying to make the curl (POST) test work. Must adapt it to make it work with several destinations, which I found on fastpower via the following grep

/var/www/ $ grep -w POST log/2017/*/*/a*log | cut -d ' ' -f 7 |sort|uniq
ngiger@fastpower /var/www/ $ grep -w POST log/2017/*/*/a*log | cut -d ' ' -f 7 |grep -c pharmasoft
ngiger@fastpower /var/www/ $ grep -w POST log/2017/*/*/a*log | cut -d ' ' -f 7 |grep -c pharmatic
ngiger@fastpower /var/www/ $ grep -w POST log/2017/*/*/a*log | cut -d ' ' -f 7 |grep -c propharma
ngiger@fastpower /var/www/ $ grep -w POST log/2017/*/*/a*log | cut -d ' ' -f 7 |grep -c volksapotheke

Remarked that in /etc/apache2/vhosts.d/ we have an entry @ScriptAlias /pharmasoft /var/www/

The difference between propharma.rbx, pharmatic.rbx, volksapotheke.rbx and sunstore.rbx are

  • transaction.partner = 'ProPharma', 'Pharmatic', 'Volksapotheke' or 'SunStore'
  • propharma.rbx, volksapotheke,rbx and sunstore add
     request.content_type = 'text/xml;charset=utf-8';  
       print xmlconv.execute_with_response(transaction)

Can I see somewhere in the saved orders which partner was used? It does not look like. The partner id is only referenced in lib/postprocess/soap.rb where it is changed to customer.acc_id || customer.party_id. Therefore I think it should be possible to handle all POST request the same way and set the transation.partner to the request_path, which would be all lowercase and not mixed case like for ProPharma.

Pushed the following commits

Posting still does not work, as in lib/conversion/sunstore_bdd.rb the transaction.model is nil. Why? In the XML-source is not transformed correctly. There are two errors

  • The rack_request defines the rack.request.form_hash as a Hash, where <?xml version" is the key. and the rest is the value. But we should have a valid XML-document.
  • Further we miss a space between to XML-identifiers, e.g. xmlns:xsi=""xmlns:xsd="". Trying to fix this problem by changing the test/data/confuse.xml with replacing line-ending by spaces.

Now I am getting the following error when parsing the XML

[1] pry(#<XmlConv::Util::Transaction>)> input_model = reader_instance.parse(@input)
=> <UNDEFINED> ... </>

Why? Because the document does not contain a root element. This is no problem.

Added a to_html method in lib/xmlconv/view/login.rb to return an empty answer for POST requests. Now the curl POST request answers with

* upload completely sent off: 629 out of 629 bytes
< HTTP/1.1 200 OK 
< Date: Tue, 06 Jun 2017 10:18:43 GMT
< Server: WEBrick/1.3.1 (Ruby/2.4.0/2016-12-24)
< Content-Length: 0
< Content-Type: text/html;charset=UTF-8
< Set-Cookie: _session_id=bf502bd91d121915676d9ea0a; path=/
* Curl_http_done: called premature == 0
* Connection #0 to host left intact

Found no easy way to close the connection to host. After fixing the owner of var/output I can cat the newly generated file

cat /var/www/

and it displays under the following content

Input	Output
<?xml version "1.0" encoding="utf-8"?>
     xmlns:xsd="" version="1.0"
     language="fr" productDescriptionDesired="true"
     communicationSoftwareId="ywesee Test"
  <client number="99" password="" />
  <orderHeader deliveryDate="2016-07-15" referenceNumber="99"/>
    <productOrderLine orderQuantity="2">
      <pharmaCode id="2508375" />
    <productOrderLine orderQuantity="2">
      <pharmaCode id="5195126" />


© 2017

Must make the bin/admin-interface work for

Pushed commits

Checking virbac_admin to find why some users must have their password resetted. The admin-interface can be run via sudo -u bbmb /usr/local/bin/bundle-240 exec ruby-240 bin/virbac_admin. But on fastpower it fails, because pry is not installed. After fixing this I get the following error

BBMB.config.load from /var/www/
Used version: sbsm 1.4.2, bbmb 2.2.9 virbac 092d5723262ba439902f726a0dcf1d1e0e145661
ch.bbmb.virbac> ODBA.cache.extent(BBMB::Model::Order).size
-> DRb::DRbServerNotFound

On oddb-ci2 we listen on port 12099 on tcp AND tcp6, whereas on fastpower we listen only on tcp6.

giger@fastpower /var/www/ $ sudo netstat -lptu | grep 12002
tcp        0      0 fastpower:12002         *:*                     LISTEN      18828/Bbmb(Virbac)  

The same is true for port 12003 virbac_yus. Why are two services for 12099 started for tcp4 AND tcp6 as on oddb-ci2, as seen by

tcp        0      0 oddb-ci2:12099*               LISTEN      307/Bbmb(Virbac)    
tcp6       0      0 oddb-ci2:12099          [::]:*                  LISTEN      1966/Bbmb(Virbac)   

On oddb-ci2 the process with ID 307 on TPC4 port 12099 was launched by the bin/virbac_admin. If I change on oddb_ci2 the server_url in etc/config.xml to TCP6 by using the line server_url: druby://::1:12099 I get also the error DRb::DRbServerNotFound

Changing the server_port on oddb_ci2 from 12099 to the port 12002 as on fastpower. Calling sudo -u bbmb bundle exec rackup opens a TCP6 port as seen by sudo netstat -ntlpu | grep 12002 which returns tcp6 0 0 ::1:12002 :::* LISTEN 20303/Bbmb(Virbac)

After changing the server_url to druby:// I get a TCP4 port tcp 0 0* LISTEN 20927/Bbmb(Virbac). And now I get again the error DRb::DRbServerNotFound. Therefore I must fix calling the service. After starting the virbac APP I can access the servic via BBMB.service. And the bin/virbac_admin begins to work. E.g

ch.bbmb.virbac> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').last.customer_id
-> 17538

Pushed commit Fix bin/virbac_admin Now on fastpower I get

ch.bbmb.virbac> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').last.customer_id
-> 88611
ch.bbmb.virbac> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').last.address_lines

But via the HTTP admin web interface I am unable to find a customer 88611. But we can find a customer 88611 via vetoquinol. Therefore the config for the bin/virbac_admin is not yet correct. Looks like we use the DB bbmb_yus and not virbac_bbmb. These DBs are specified in the etc/yus.yml. Are they mixed up? Yes in bin/virbac_admin we first loaded the default config, whereas in the the etc/config.yml gets loaded first. Fixed with commit Ensure that bin/virbac_admin and read first etc/config.yml

After pulling these changes on fastpower bin/virbac_admin finally works fine and displays

ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').address_lines
-> ["Balcer", "", "& Colette Berner", "Weidstrasse 7", "8580 Amriswil"]
ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').email
ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').orders.size
-> 1
ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').orders.last
-> #<BBMB::Model::Order:0x007f45c69c2698>
view · edit · sidebar · attach · print · history
Page last modified on June 06, 2017, at 05:29 PM