Comments (5)
Have you tried to follow the guide (explained here)?
from xsd2php.
I have tried but I am getting the error:
[17-May-2017 18:33:14 America/New_York] PHP Fatal error: Uncaught exception 'JMS\Serializer\Exception\XmlErrorException' with message '[FATAL] Specification mandate value for attribute xml
in (line: 1, column: 10)' in /home/dev/public_html/application/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php:84
Stack trace:
#0 /home/dev/public_html/application/vendor/jms/serializer/src/JMS/Serializer/Serializer.php(128): JMS\Serializer\XmlDeserializationVisitor->prepare('<some xml/>')
#1 [internal function]: JMS\Serializer\Serializer->JMS\Serializer\{closure}(Object(JMS\Serializer\XmlDeserializationVisitor))
#2 /home/dev/public_html/application/vendor/phpoption/phpoption/src/PhpOption/Some.php(89): call_user_func(Object(Closure), Object(JMS\Serializer\XmlDeserializationVisitor))
#3 /home/dev/public_html/application/vendor/jms/serializer/src/JMS/Serializer/Serializer.php(132): PhpOption\Some->map(Object(Closure))
#4 /home/dev/public_html/application/controllers/test.php(37): JMS\Serializer\Serializer->deserialize('<some xml/>', 'TestNs\\MyObject', 'xm in /home/dev/public_html/application/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php on line 84
Here is code:
$serializerBuilder = SerializerBuilder::create();
$serializerBuilder->addMetadataDir('/home/dev/public_html/soap/metadata', 'TestNs');
$serializerBuilder->configureHandlers(function (HandlerRegistryInterface $handler) use ($serializerBuilder) {
$serializerBuilder->addDefaultHandlers();
$handler->registerSubscribingHandler(new BaseTypesHandler()); // XMLSchema List handling
$handler->registerSubscribingHandler(new XmlSchemaDateHandler()); // XMLSchema date handling
});
$serializer = $serializerBuilder->build();
// deserialize the XML into Demo\MyObject object
$object = $serializer->deserialize('<some xml/>', 'TestNs\MyObject', 'xml');
// some code ....
// serialize the Demo\MyObject back into XML
$newXml = $serializer->serialize($object, 'xml');
I suspect that something else is supposed to go into the deserialize method besides '' but I don't know what.
from xsd2php.
Ok so I decided to start over using a simple xsd I found:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xsd"
targetNamespace="http://tempuri.org/PurchaseOrderSchema.xsd"
elementFormDefault="qualified">
<xsd:element name="PurchaseOrder" type="tns:PurchaseOrderType"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="ShipTo" type="tns:USAddress" maxOccurs="2"/>
<xsd:element name="BillTo" type="tns:USAddress"/>
</xsd:sequence>
<xsd:attribute name="OrderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:integer"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
</xsd:schema>
config.yml
xsd2php:
namespaces:
'http://tempuri.org/PurchaseOrderSchema.xsd': 'TestNs\MyApp'
destinations_php:
'TestNs\MyApp': soap2/src
destinations_jms:
'TestNs\MyApp': soap2/metadata
naming_strategy: short # optional and default
path_generator: psr4 # optional and default
Generated PHP classes and metadata OK. The generated PHP classes are PurchaseOrder.php, PurchaseOrderType.php, and USAddressType.php.
I don't understand what I am supposed to do next. Is there a start to finish example anywhere?
from xsd2php.
it looks your XML is not well formatted (this is an example of a document that triggers a similar error http://www.getsymphony.com/discuss/thread/107805/)
from xsd2php.
@rps-repo
Hii,
Please look at this https://github.com/goetas-webservices/xsd2php/issues/34 I ran into similar problem,if you need to generate XML, you first create the object set values to fields and then serialize it to XML.
from xsd2php.
Related Issues (20)
- Problems with JMS-Metadata-Generator HOT 4
- Improper PHP code form choice element HOT 2
- Unable to generate PHP classes from XSD file HOT 3
- Declaration of Xsd2PhpExtension::getAlias() must be compatible with Symfony\Component\DependencyInjection\Extension\Extension::getAlias() HOT 4
- Better Handling of xsd:choice
- [Feature Request] Add option to add PHP type declarations
- Handling of xsd:squence with maxOccurs="unbounded"
- Composer requirements version HOT 3
- still uses psr/log:^1.0 - Please add support for psr/log:^3.0 and ^2.0 HOT 3
- CDATA sections not being disabled in XML despite setting xml_cdata to false in goetas-webservices/xsd2php HOT 2
- Can you help me create config.yml
- where are the simpleType restrictions?
- Wrong rendering of PHPDocs in generated classes HOT 2
- Possibility of upgrade goetas-webservices/xsd-reader dependency to 0.4.1 HOT 1
- Uncaught TypeError issue after upgrading to 0.4.11 HOT 1
- Not escaping */ in php comments
- compatible to symfony 7.0 HOT 5
- xs:Choice of xs:Sequence not supported? HOT 2
- ComplexType with single Sequence fails to generate underlying type class
- xsd:sequence produces Uncaught TypeError like xsd:group in #163 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xsd2php.