xsd-reader icon indicating copy to clipboard operation
xsd-reader copied to clipboard

Some servers answer with HTTP Status 500 without user agent set

Open jfastnacht opened this issue 9 years ago • 4 comments
trafficstars

Tried to convert the REQIF definition with xsd2php and got an error which is caused by xsd-reader:

> C:\webserver\php-7.0.8\composer.bat build

C:\Users\fastnacht\PhpstormProjects\staffgraph-req>"C:\webserver\php-7.0.8\php.exe" "C:\webserver\php-7.0.8\composer.phar" build 
> xsd2php convert:php reqif.xsd --ns-map=http://www.omg.org/spec/ReqIF/20110401/reqif.xsd;jfastnacht/REQIF --ns-dest=jfastnacht/REQIF/;src/jfastnacht/REQIF
Namespaces:
    XML namepsace: http://www.omg.org/spec/ReqIF/20110401/reqif.xsd => PHP namepsace: jfastnacht/REQIF
Target directories:
    PHP namepsace: jfastnacht/REQIF/ => Destination directory: src/jfastnacht/REQIF
Reading reqif.xsd

Script xsd2php convert:php reqif.xsd --ns-map=http://www.omg.org/spec/ReqIF/20110401/reqif.xsd;jfastnacht/REQIF --ns-dest=jfastnacht/REQIF/;src/jfastnacht/REQIF handling the build event returned with an error

Warning: DOMDocument::load(http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-datatypes-1.xsd): failed to open stream: HTTP request failed! HTTP/1.0 500 Server Error
 in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webservices\xsd-reader\src\SchemaReader.php on line 758

Warning: DOMDocument::load(): I/O warning : failed to load external entity "http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-datatypes-1.xsd" in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webservices\xsd-reader\src\SchemaReader.php on line 758


  [GoetasWebservices\XML\XSDReader\Exception\IOException]                      
  Can't load the file http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-  
  datatypes-1.xsd                                                              


convert:php [--ns-map NS-MAP] [--ns-dest NS-DEST] [--alias-map ALIAS-MAP] [--naming-strategy NAMING-STRATEGY] [--] <src> (<src>)...

PHP Warning:  DOMDocument::load(http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-datatypes-1.xsd): failed to open stream: HTTP request failed! HTTP/1.0 500 Server Error
 in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webservices\xsd-reader\src\SchemaReader.php on line 758
PHP Warning:  DOMDocument::load(): I/O warning : failed to load external entity "http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-datatypes-1.xsd" in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webservices\xsd-reader\src\SchemaReader.php on line 758

  [RuntimeException]                                                           
  Error Output:                                                                


    [GoetasWebservices\XML\XSDReader\Exception\IOException]                    

    Can't load the file http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtm  
  l-                                                                           
    datatypes-1.xsd                                                            



  convert:php [--ns-map NS-MAP] [--ns-dest NS-DEST] [--alias-map ALIAS-MAP] [  
  --naming-strategy NAMING-STRATEGY] [--] <src> (<src>)...                     
  PHP Warning:  DOMDocument::load(http://www.w3.org/TR/xhtml-modularization/S  
  CHEMA/xhtml-datatypes-1.xsd): failed to open stream: HTTP request failed! H  
  TTP/1.0 500 Server Error                                                     
   in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webser  
  vices\xsd-reader\src\SchemaReader.php on line 758                            
  PHP Warning:  DOMDocument::load(): I/O warning : failed to load external en  
  tity "http://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtml-datatypes-1.xs  
  d" in C:\Users\fastnacht\PhpstormProjects\staffgraph-req\vendor\goetas-webs  
  ervices\xsd-reader\src\SchemaReader.php on line 758                          


build [--dev] [--no-dev] [--] [<args>]...


Process finished with exit code 1 at 13:53:33.
Execution time: 16.898 ms.

Composer build script:

"scripts": {
  "build": "xsd2php convert:php reqif.xsd --ns-map=http://www.omg.org/spec/ReqIF/20110401/reqif.xsd;jfastnacht/REQIF --ns-dest=jfastnacht/REQIF/;src/jfastnacht/REQIF"
}

Fixed it with a comment on https://secure.php.net/manual/de/domdocument.load.php#91384 by adding:

$opts = array(
    'http' => array(
        'user_agent' => 'PHP libxml agent',
    )
);
$context = stream_context_create($opts);
libxml_set_streams_context($context);

between https://github.com/goetas-webservices/xsd-reader/blob/f5763c5ab6b15aa5b5de21fe72f3ad97f8a293ed/src/SchemaReader.php#L757-L758

Might help someone else with the same problem. This is just a quick and dirty solution if you need it right now.

jfastnacht avatar Sep 12 '16 12:09 jfastnacht

https://www.w3.org/TR/xhtml-modularization/SCHEMA/xhtm%20l-%20datatypes-1.xsd gives 404 not found

Looks that your projects references it somewhere

goetas avatar Sep 12 '16 14:09 goetas

Fixed it with a comment on https://secure.php.net/manual/de/domdocument.load.php#91384 by adding:

i see, interesting

goetas avatar Sep 12 '16 14:09 goetas

Was just playing around with xsd2php, have to take a deeper look to get other the other stuff working, but I thought it might be a good idea to share this before continuing.

jfastnacht avatar Sep 12 '16 14:09 jfastnacht

100% good idea. I was not aware of this issue

goetas avatar Sep 12 '16 14:09 goetas