Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding xmlns:xsi XMLSchema-instance #36

Open
mdesign83 opened this issue Feb 8, 2019 · 5 comments
Open

Adding xmlns:xsi XMLSchema-instance #36

mdesign83 opened this issue Feb 8, 2019 · 5 comments

Comments

@mdesign83
Copy link

Hi,

I would like to port my SoapClient code to goetas-webservices but I'm running a problem where the server requires xsi:type attribute on the record.
How can I add these type attributes to the generated xml request?

Thanks,
Karoly

@mdesign83
Copy link
Author

I would like to achieve this:

<?xml version="1.0" ?>
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <Name>Fred</Name> 
    <HomeAddress xsi:type="USAddressType"> 
        <Line1>234 Lancaseter Av</Line1> 
        <Line2>SmallsVille</Line2> 
        <State>Florida</State> 
        <Zipcode>34543</Zipcode> 
    </HomeAddress> 
</Person>

https://www.liquid-technologies.com/xml-schema-tutorial/xsd-extending-types

@goetas
Copy link
Member

goetas commented Feb 10, 2019

From the readme of this project:

Only document/literal style is supported and the webservice should follow the WS-I guidelines.

Im not sure if the XMLSchema-instance usage you are tying is WS-I and document/literal style compliant

@mdesign83
Copy link
Author

mdesign83 commented Feb 13, 2019

I found a solution which works for me: https://github.com/schmittjoh/serializer/issues/433#issuecomment-324246156.
I modified the listener to a subscriber and then I can inject it before building the serializer:

$serializer = SoapContainerBuilder::createSerializerBuilderFromContainer($container, null, SoapClientContainer::getMetadataDir());
$serializer->configureListeners(function(EventDispatcher $handlerBuilder) {
    $jmsXsi = new JmsXsiTypeSubscriber(
        [
            'namespace' => 'http://schemas.datacontract.org/...',
            'type'      => 'DummyType',
            'class'     => DummyType::class,
        ], [
              //...
        ]
    );
    $handlerBuilder->addSubscriber($jmsXsi);
});
$serializer = $serializer->build();

Any advice is welcome.

@goetas
Copy link
Member

goetas commented Feb 13, 2019

Well, it might work... but you did not answer to my previous comment:

Im not sure if the XMLSchema-instance usage you are tying is WS-I and document/literal style compliant

@mdesign83
Copy link
Author

I'm affraid it's not. It is RPC/encoded, so "Although it is legal WSDL, RPC/encoded is not WS-I compliant."
https://www.ibm.com/developerworks/library/ws-whichwsdl/

@mdesign83 mdesign83 changed the title Missing xmlns:xsi XMLSchema-instance Adding xmlns:xsi XMLSchema-instance Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants